exception: add InvalidEnumString error
Change-Id: I138d468cc5e16241b450108eedf79c4a4c317d87
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/sdbusplus/exception.hpp b/sdbusplus/exception.hpp
index f5f6ab6..a0e628e 100644
--- a/sdbusplus/exception.hpp
+++ b/sdbusplus/exception.hpp
@@ -21,6 +21,36 @@
{
};
+/** Exception for when an invalid conversion from string to enum is
+ * attempted. */
+struct InvalidEnumString final : public internal_exception
+{
+ static constexpr auto errName =
+ "org.openbmc_project.sdbusplus.Error.InvalidEnumString";
+ static constexpr auto errDesc =
+ "An enumeration mapping was attempted for which no valid enumeration "
+ "value exists.";
+ static constexpr auto errWhat =
+ "org.openbmc_project.sdbusplus.Error.InvalidEnumString: "
+ "An enumeration mapping was attempted for which no valid enumeration "
+ "value exists.";
+
+ const char* name() const noexcept override
+ {
+ return errName;
+ }
+
+ const char* description() const noexcept override
+ {
+ return errDesc;
+ }
+
+ const char* what() const noexcept override
+ {
+ return errWhat;
+ }
+};
+
} // namespace exception
using exception_t = exception::exception;