10237971cSBrad Bishop #pragma once
20237971cSBrad Bishop 
30237971cSBrad Bishop #include <stdexcept>
40237971cSBrad Bishop 
50237971cSBrad Bishop namespace phosphor
60237971cSBrad Bishop {
70237971cSBrad Bishop namespace inventory
80237971cSBrad Bishop {
90237971cSBrad Bishop namespace manager
100237971cSBrad Bishop {
110237971cSBrad Bishop 
120237971cSBrad Bishop // TODO: Use proper error generation techniques
130237971cSBrad Bishop // https://github.com/openbmc/openbmc/issues/1125
140237971cSBrad Bishop 
150237971cSBrad Bishop /** @class InterfaceError
160237971cSBrad Bishop  *  @brief Exception class for unrecognized interfaces.
170237971cSBrad Bishop  */
180237971cSBrad Bishop class InterfaceError final : public std::invalid_argument
190237971cSBrad Bishop {
200237971cSBrad Bishop   public:
210237971cSBrad Bishop     ~InterfaceError() = default;
220237971cSBrad Bishop     InterfaceError() = delete;
230237971cSBrad Bishop     InterfaceError(const InterfaceError&) = delete;
240237971cSBrad Bishop     InterfaceError(InterfaceError&&) = default;
250237971cSBrad Bishop     InterfaceError& operator=(const InterfaceError&) = delete;
260237971cSBrad Bishop     InterfaceError& operator=(InterfaceError&&) = default;
270237971cSBrad Bishop 
280237971cSBrad Bishop     /** @brief Construct an interface error.
290237971cSBrad Bishop      *
300237971cSBrad Bishop      *  @param[in] msg - The message to be returned by what().
310237971cSBrad Bishop      *  @param[in] iface - The failing interface name.
320237971cSBrad Bishop      */
InterfaceError(const char * msg,const std::string & iface)33615b2a8fSBrad Bishop     InterfaceError(const char* msg, const std::string& iface) :
34615b2a8fSBrad Bishop         std::invalid_argument(msg), interface(iface)
35*a83db30eSBrad Bishop     {}
360237971cSBrad Bishop 
370237971cSBrad Bishop     /** @brief Log the exception message to the systemd journal. */
380237971cSBrad Bishop     void log() const;
390237971cSBrad Bishop 
400237971cSBrad Bishop   private:
410237971cSBrad Bishop     std::string interface;
420237971cSBrad Bishop };
430237971cSBrad Bishop 
440237971cSBrad Bishop } // namespace manager
450237971cSBrad Bishop } // namespace inventory
460237971cSBrad Bishop } // namespace phosphor
470237971cSBrad Bishop 
480237971cSBrad Bishop // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
49