blob: 37f8d81b8434f2faded2d51f8a400e3f52761c1b [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{
Brad Bishop615b2a82018-03-29 10:32:41 -040020 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;
Brad Bishop02379712017-01-31 22:24:27 -050027
Brad Bishop615b2a82018-03-29 10:32:41 -040028 /** @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(const char* msg, const std::string& iface) :
34 std::invalid_argument(msg), interface(iface)
Brad Bishopa83db302020-12-06 14:51:23 -050035 {}
Brad Bishop02379712017-01-31 22:24:27 -050036
Brad Bishop615b2a82018-03-29 10:32:41 -040037 /** @brief Log the exception message to the systemd journal. */
38 void log() const;
Brad Bishop02379712017-01-31 22:24:27 -050039
Brad Bishop615b2a82018-03-29 10:32:41 -040040 private:
41 std::string interface;
Brad Bishop02379712017-01-31 22:24:27 -050042};
43
44} // namespace manager
45} // namespace inventory
46} // namespace phosphor