summaryrefslogtreecommitdiffstats
path: root/errors.hpp
blob: cc3e3064bed96a2b86cb7cbecd2d3a5e11a2402c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once

#include <stdexcept>

namespace phosphor
{
namespace inventory
{
namespace manager
{

// TODO: Use proper error generation techniques
// https://github.com/openbmc/openbmc/issues/1125

/** @class InterfaceError
 *  @brief Exception class for unrecognized interfaces.
 */
class InterfaceError final : public std::invalid_argument
{
  public:
    ~InterfaceError() = default;
    InterfaceError() = delete;
    InterfaceError(const InterfaceError&) = delete;
    InterfaceError(InterfaceError&&) = default;
    InterfaceError& operator=(const InterfaceError&) = delete;
    InterfaceError& operator=(InterfaceError&&) = default;

    /** @brief Construct an interface error.
     *
     *  @param[in] msg - The message to be returned by what().
     *  @param[in] iface - The failing interface name.
     */
    InterfaceError(const char* msg, const std::string& iface) :
        std::invalid_argument(msg), interface(iface)
    {
    }

    /** @brief Log the exception message to the systemd journal. */
    void log() const;

  private:
    std::string interface;
};

} // namespace manager
} // namespace inventory
} // namespace phosphor

// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
OpenPOWER on IntegriCloud