blob: 37dbac9a690a7e6ff5562d543ec4fe3ab47516bc [file] [log] [blame]
Patrick Williamsf4a6f412016-11-11 13:47:29 -06001#pragma once
2
3#include <exception>
4
5namespace sdbusplus
6{
7
8namespace exception
9{
10
Patrick Williams1a283062016-11-13 19:05:10 -060011/** Base exception class for all sdbusplus exceptions, including those created
12 * by the bindings. */
Patrick Williamsf4a6f412016-11-11 13:47:29 -060013struct exception : public std::exception
14{
Patrick Williamsea241442016-11-15 14:41:13 -060015 virtual const char* name() const noexcept = 0;
16 virtual const char* description() const noexcept = 0;
Patrick Williamsf4a6f412016-11-11 13:47:29 -060017};
18
Patrick Williams1a283062016-11-13 19:05:10 -060019/** base exception class for all errors generated by sdbusplus itself. */
20struct internal_exception : public exception
21{
22};
23
Patrick Williams59b70d12016-11-16 16:11:25 -060024/** Exception for when an invalid conversion from string to enum is
25 * attempted. */
26struct InvalidEnumString final : public internal_exception
27{
28 static constexpr auto errName =
Patrick Williams02d96752017-04-19 07:52:29 -050029 "xyz.openbmc_project.sdbusplus.Error.InvalidEnumString";
Patrick Williams59b70d12016-11-16 16:11:25 -060030 static constexpr auto errDesc =
31 "An enumeration mapping was attempted for which no valid enumeration "
32 "value exists.";
33 static constexpr auto errWhat =
Patrick Williams02d96752017-04-19 07:52:29 -050034 "xyz.openbmc_project.sdbusplus.Error.InvalidEnumString: "
Patrick Williams59b70d12016-11-16 16:11:25 -060035 "An enumeration mapping was attempted for which no valid enumeration "
36 "value exists.";
37
Patrick Williams93b0e702017-04-18 11:19:45 -050038 const char* name() const noexcept override;
39 const char* description() const noexcept override;
40 const char* what() const noexcept override;
Patrick Williams59b70d12016-11-16 16:11:25 -060041};
42
Patrick Williamsf4a6f412016-11-11 13:47:29 -060043} // namespace exception
44
45using exception_t = exception::exception;
Patrick Williams1a283062016-11-13 19:05:10 -060046using internal_exception_t = exception::internal_exception;
Patrick Williamsf4a6f412016-11-11 13:47:29 -060047
48} // namespace sdbusplus