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/tests/src/test_conversion.cpp b/tests/src/test_conversion.cpp
index 6a69e39..22b108e 100644
--- a/tests/src/test_conversion.cpp
+++ b/tests/src/test_conversion.cpp
@@ -38,6 +38,17 @@
              std::make_pair<std::string_view, Enum>("two", Enum::two)}};
 };
 
+namespace utils
+{
+
+template <>
+struct EnumTraits<TestConversion::Enum>
+{
+    static constexpr auto propertyName = ConstexprString{"Enum"};
+};
+
+} // namespace utils
+
 TEST_F(TestConversion, passValueInRangeExpectToGetValidOutput)
 {
     EXPECT_EQ(toEnum(0), Enum::zero);
@@ -46,8 +57,8 @@
 
 TEST_F(TestConversion, passInvalidValueExpectToThrowException)
 {
-    EXPECT_THROW(toEnum(-1), sdbusplus::exception::SdBusError);
-    EXPECT_THROW(toEnum(3), sdbusplus::exception::SdBusError);
+    EXPECT_THROW(toEnum(-1), errors::InvalidArgument);
+    EXPECT_THROW(toEnum(3), errors::InvalidArgument);
 }
 
 TEST_F(TestConversion, convertsToUnderlyingType)
@@ -73,11 +84,10 @@
 
 TEST_F(TestConversion, enumToStringThrowsWhenUknownEnumPassed)
 {
-    EXPECT_THROW(enumToString(static_cast<Enum>(77)),
-                 sdbusplus::exception::SdBusError);
+    EXPECT_THROW(enumToString(static_cast<Enum>(77)), errors::InvalidArgument);
 }
 
 TEST_F(TestConversion, toEnumThrowsWhenUknownStringPassed)
 {
-    EXPECT_THROW(toEnum("four"), sdbusplus::exception::SdBusError);
+    EXPECT_THROW(toEnum("four"), errors::InvalidArgument);
 }
diff --git a/tests/src/test_make_id_name.cpp b/tests/src/test_make_id_name.cpp
index e88a8ac..4bde5db 100644
--- a/tests/src/test_make_id_name.cpp
+++ b/tests/src/test_make_id_name.cpp
@@ -30,7 +30,7 @@
 TEST_F(ScenarioNameProvided, throwsWhenProvidedNameIsTooLong)
 {
     EXPECT_THROW(this->makeIdName("", getTooLongName()),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
 }
 
 class TestMakeIdNameNameProvided : public ScenarioNameProvided
@@ -95,13 +95,11 @@
 TYPED_TEST(TestMakeIdName, throwsWhenProvidedIdContainsIncorrectCharacters)
 {
     EXPECT_THROW(this->makeIdName("Id%@%!@%!%()%fooo/Id", "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName("Id/Id%@%!@%!%()%fooo", "name"),
-                 sdbusplus::exception::SdBusError);
-    EXPECT_THROW(this->makeIdName("/123", "trigger"),
-                 sdbusplus::exception::SdBusError);
-    EXPECT_THROW(this->makeIdName("/123/", "trigger"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
+    EXPECT_THROW(this->makeIdName("/123", "trigger"), errors::InvalidArgument);
+    EXPECT_THROW(this->makeIdName("/123/", "trigger"), errors::InvalidArgument);
 }
 
 TYPED_TEST(TestMakeIdName, throwsWhenProvidedIdContainsTooLongSegment)
@@ -109,37 +107,33 @@
     std::string longPrefix = getTooLongPrefix();
     std::string longSuffix = getTooLongId();
     EXPECT_THROW(this->makeIdName(longPrefix + "/", "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName(longPrefix + "/Id", "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName(longPrefix + "/" + longSuffix, "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName("Prefix/" + longSuffix, "name"),
-                 sdbusplus::exception::SdBusError);
-    EXPECT_THROW(this->makeIdName(longSuffix, "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
+    EXPECT_THROW(this->makeIdName(longSuffix, "name"), errors::InvalidArgument);
 }
 
 TYPED_TEST(TestMakeIdName, throwsWhenProvidedIdOrPrefixTooLong)
 {
     EXPECT_THROW(this->makeIdName(getTooLongId(), "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName(getTooLongPrefix() + "/Id", "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName("Prefix/" + getTooLongId(), "trigger"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
 }
 
 TYPED_TEST(TestMakeIdName, throwsWhenIdContainsMoreThanOneSlash)
 {
-    EXPECT_THROW(this->makeIdName("/12/", "name"),
-                 sdbusplus::exception::SdBusError);
-    EXPECT_THROW(this->makeIdName("12//", "name"),
-                 sdbusplus::exception::SdBusError);
-    EXPECT_THROW(this->makeIdName("12//123", "name"),
-                 sdbusplus::exception::SdBusError);
+    EXPECT_THROW(this->makeIdName("/12/", "name"), errors::InvalidArgument);
+    EXPECT_THROW(this->makeIdName("12//", "name"), errors::InvalidArgument);
+    EXPECT_THROW(this->makeIdName("12//123", "name"), errors::InvalidArgument);
     EXPECT_THROW(this->makeIdName("12/12/123", "name"),
-                 sdbusplus::exception::SdBusError);
+                 errors::InvalidArgument);
 }
 
 TYPED_TEST(TestMakeIdName, usesNameWhenThereAreConflicts)
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index f593fd4..51140b7 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -94,7 +94,7 @@
                 return utils::enumToString(v);
             }));
         properties.emplace_back("Interval", params.interval().count());
-        properties.emplace_back("MetricParams",
+        properties.emplace_back("ReadingParameters",
                                 toReadingParameters(params.metricParameters()));
 
         return addReport(properties);
@@ -157,7 +157,7 @@
     EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _));
     EXPECT_CALL(reportFactoryMock,
                 make("Report"s, "Report"s, ReportingType::onRequest,
-                     std::vector<ReportAction>{}, Milliseconds{}, 0,
+                     std::vector<ReportAction>{}, Milliseconds{}, 256,
                      ReportUpdates::overwrite, _, _,
                      std::vector<LabeledMetricParameters>{}, true, Readings{}))
         .WillOnce(Return(ByMove(std::move(reportMockPtr))));
@@ -432,7 +432,7 @@
 
     auto [ec, path] = addReport(reportParams);
 
-    EXPECT_THAT(ec.value(), Eq(boost::system::errc::argument_list_too_long));
+    EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument));
     EXPECT_THAT(path, Eq(std::string()));
 }
 
@@ -457,7 +457,7 @@
 
     auto [ec, path] = addReport(reportParams);
 
-    EXPECT_THAT(ec.value(), Eq(boost::system::errc::argument_list_too_long));
+    EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument));
     EXPECT_THAT(path, Eq(std::string()));
 }