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.cpp b/src/errors.cpp
new file mode 100644
index 0000000..fe88fd0
--- /dev/null
+++ b/src/errors.cpp
@@ -0,0 +1,44 @@
+#include "errors.hpp"
+
+#include <system_error>
+
+namespace errors
+{
+
+using namespace std::literals::string_literals;
+
+InvalidArgument::InvalidArgument(std::string_view propertyNameArg) :
+    propertyName(propertyNameArg),
+    errWhatDetailed("Invalid argument was given for property: "s +
+                    description())
+{}
+
+InvalidArgument::InvalidArgument(std::string_view propertyNameArg,
+                                 std::string_view info) :
+    propertyName(propertyNameArg),
+    errWhatDetailed(
+        ("Invalid argument was given for property: "s + description() + ". "s)
+            .append(info))
+{}
+
+const char* InvalidArgument::name() const noexcept
+{
+    return "org.freedesktop.DBus.Error.InvalidArgs";
+}
+
+const char* InvalidArgument::description() const noexcept
+{
+    return propertyName.c_str();
+}
+
+const char* InvalidArgument::what() const noexcept
+{
+    return errWhatDetailed.c_str();
+}
+
+int InvalidArgument::get_errno() const noexcept
+{
+    return static_cast<int>(std::errc::invalid_argument);
+}
+
+} // namespace errors