blob: 1fa44924f03adee1b3d5ee9cb5630fa456492158 [file] [log] [blame]
Brad Bishop02379712017-01-31 22:24:27 -05001#pragma once
2
3#include <stdexcept>
4
5namespace phosphor
6{
7namespace inventory
8{
9namespace manager
10{
11
12// TODO: Use proper error generation techniques
13// https://github.com/openbmc/openbmc/issues/1125
14
15/** @class InterfaceError
16 * @brief Exception class for unrecognized interfaces.
17 */
18class InterfaceError final : public std::invalid_argument
19{
20 public:
21 ~InterfaceError() = default;
22 InterfaceError() = delete;
23 InterfaceError(const InterfaceError&) = delete;
24 InterfaceError(InterfaceError&&) = default;
25 InterfaceError& operator=(const InterfaceError&) = delete;
26 InterfaceError& operator=(InterfaceError&&) = default;
27
28 /** @brief Construct an interface error.
29 *
30 * @param[in] msg - The message to be returned by what().
31 * @param[in] iface - The failing interface name.
32 */
33 InterfaceError(
34 const char* msg,
35 const std::string& iface) :
36 std::invalid_argument(msg),
37 interface(iface) {}
38
39 /** @brief Log the exception message to the systemd journal. */
40 void log() const;
41
42 private:
43
44 std::string interface;
45};
46
47} // namespace manager
48} // namespace inventory
49} // namespace phosphor
50
51// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4