Add custom exception class and type

The commit adds few custom exception class and type so that exact
exception can be thrown for a failure.
This is required to detect the type of failure and log appropriate PEL
for the error. With just throwing runtime error in most of the cases it
is not possible to detect the reason for failure at catching point.

Change-Id: I672c3c5fd6d289b8e6943b9a22836acfb9e6b04b
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/exceptions.hpp b/vpd-manager/include/exceptions.hpp
index a787d08..12ab4eb 100644
--- a/vpd-manager/include/exceptions.hpp
+++ b/vpd-manager/include/exceptions.hpp
@@ -154,4 +154,76 @@
     explicit GpioException(const std::string& msg) : Exception(msg) {}
 };
 
+/** @class DbusException
+ *  @brief Custom handler for Dbus exception.
+ *
+ *  This class extends Exceptions class and define
+ *  type for DBus related exception in VPD.
+ */
+class DbusException : public Exception
+{
+  public:
+    // deleted methods
+    DbusException() = delete;
+    DbusException(const DbusException&) = delete;
+    DbusException(DbusException&&) = delete;
+    DbusException& operator=(const DbusException&) = delete;
+
+    // default destructor
+    ~DbusException() = default;
+
+    /** @brief constructor
+     *  @param[in] msg - string to define exception
+     */
+    explicit DbusException(const std::string& msg) : Exception(msg) {}
+};
+
+/** @class FirmwareException
+ *  @brief Custom handler for firmware exception.
+ *
+ *  This class extends Exceptions class and define
+ *  type for generic firmware related exception in VPD.
+ */
+class FirmwareException : public Exception
+{
+  public:
+    // deleted methods
+    FirmwareException() = delete;
+    FirmwareException(const FirmwareException&) = delete;
+    FirmwareException(FirmwareException&&) = delete;
+    FirmwareException& operator=(const FirmwareException&) = delete;
+
+    // default destructor
+    ~FirmwareException() = default;
+
+    /** @brief constructor
+     *  @param[in] msg - string to define exception
+     */
+    explicit FirmwareException(const std::string& msg) : Exception(msg) {}
+};
+
+/** @class EepromException
+ *  @brief Custom handler for EEPROM exception.
+ *
+ *  This class extends Exceptions class and define
+ *  type for EEPROM related exception in VPD.
+ */
+class EepromException : public Exception
+{
+  public:
+    // deleted methods
+    EepromException() = delete;
+    EepromException(const EepromException&) = delete;
+    EepromException(EepromException&&) = delete;
+    EepromException& operator=(const EepromException&) = delete;
+
+    // default destructor
+    ~EepromException() = default;
+
+    /** @brief constructor
+     *  @param[in] msg - string to define exception
+     */
+    explicit EepromException(const std::string& msg) : Exception(msg) {}
+};
+
 } // namespace vpd
diff --git a/vpd-manager/include/types.hpp b/vpd-manager/include/types.hpp
index 314aebd..37affa7 100644
--- a/vpd-manager/include/types.hpp
+++ b/vpd-manager/include/types.hpp
@@ -182,7 +182,9 @@
     DbusFailure,
     InvalidSystem,
     EssentialFru,
-    GpioError
+    GpioError,
+    InternalFailure, /* Should be used for any generic firmware failure */
+    FruMissing /* Should be used in case of presence failure */
 };
 
 using InventoryCalloutData = std::tuple<std::string, CalloutPriority>;
diff --git a/vpd-manager/src/event_logger.cpp b/vpd-manager/src/event_logger.cpp
index 11861d1..eb2f470 100644
--- a/vpd-manager/src/event_logger.cpp
+++ b/vpd-manager/src/event_logger.cpp
@@ -39,7 +39,10 @@
          "com.ibm.VPD.Error.UnknownSystemType"},
         {types::ErrorType::EssentialFru,
          "com.ibm.VPD.Error.RequiredFRUMissing"},
-        {types::ErrorType::GpioError, "com.ibm.VPD.Error.GPIOError"}};
+        {types::ErrorType::GpioError, "com.ibm.VPD.Error.GPIOError"},
+        {types::ErrorType::InternalFailure,
+         "xyz.openbmc_project.Common.Error.InternalFailure"},
+        {types::ErrorType::FruMissing, "com.ibm.VPD.Error.RequiredFRUMissing"}};
 
 const std::unordered_map<types::CalloutPriority, std::string>
     EventLogger::m_priorityMap = {