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