Redesigned error handling
Current error handling send only error code, which is not enough to
display detailed information. New error handling in additional to
error code send property name. This allows to send meaningful messages
back to used about errors.
Tested:
- Old redfish code properly handles errors (reads only error_code)
- Redfish version which read property name from error displays more
detailed error information
Change-Id: I54caa20881ac3f3e38cb295a3aa95ddab491303f
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/errors.hpp b/src/errors.hpp
new file mode 100644
index 0000000..e542787
--- /dev/null
+++ b/src/errors.hpp
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <sdbusplus/exception.hpp>
+
+#include <string>
+#include <string_view>
+
+namespace errors
+{
+
+class InvalidArgument final : public sdbusplus::exception::internal_exception
+{
+ public:
+ explicit InvalidArgument(std::string_view propertyName);
+ InvalidArgument(std::string_view propertyName, std::string_view info);
+
+ const char* name() const noexcept override;
+ const char* description() const noexcept override;
+ const char* what() const noexcept override;
+ int get_errno() const noexcept override;
+
+ std::string propertyName;
+
+ private:
+ std::string errWhatDetailed;
+};
+
+} // namespace errors