Brad Bishop | 0237971 | 2017-01-31 22:24:27 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdexcept> |
| 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace inventory |
| 8 | { |
| 9 | namespace 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 | */ |
| 18 | class InterfaceError final : public std::invalid_argument |
| 19 | { |
Brad Bishop | 615b2a8 | 2018-03-29 10:32:41 -0400 | [diff] [blame] | 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; |
Brad Bishop | 0237971 | 2017-01-31 22:24:27 -0500 | [diff] [blame] | 27 | |
Brad Bishop | 615b2a8 | 2018-03-29 10:32:41 -0400 | [diff] [blame] | 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(const char* msg, const std::string& iface) : |
| 34 | std::invalid_argument(msg), interface(iface) |
Brad Bishop | a83db30 | 2020-12-06 14:51:23 -0500 | [diff] [blame] | 35 | {} |
Brad Bishop | 0237971 | 2017-01-31 22:24:27 -0500 | [diff] [blame] | 36 | |
Brad Bishop | 615b2a8 | 2018-03-29 10:32:41 -0400 | [diff] [blame] | 37 | /** @brief Log the exception message to the systemd journal. */ |
| 38 | void log() const; |
Brad Bishop | 0237971 | 2017-01-31 22:24:27 -0500 | [diff] [blame] | 39 | |
Brad Bishop | 615b2a8 | 2018-03-29 10:32:41 -0400 | [diff] [blame] | 40 | private: |
| 41 | std::string interface; |
Brad Bishop | 0237971 | 2017-01-31 22:24:27 -0500 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | } // namespace manager |
| 45 | } // namespace inventory |
| 46 | } // namespace phosphor |
| 47 | |
| 48 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |