Exception class:Method to get error type

This commit has method to get error type from the custom exception class
derived from class Exception.

Change-Id: Iaff75f5ce6dcf90b9d2dc031ded2e7e03806bbc0
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
diff --git a/vpd-manager/include/exceptions.hpp b/vpd-manager/include/exceptions.hpp
index 12ab4eb..7109453 100644
--- a/vpd-manager/include/exceptions.hpp
+++ b/vpd-manager/include/exceptions.hpp
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "types.hpp"
+
 #include <stdexcept>
 
 namespace vpd
@@ -39,6 +41,8 @@
         return m_errMsg.c_str();
     }
 
+    // TODO: Create getErrorType api by defining VPD default error type
+
   private:
     /** @brief string to hold the reason of exception */
     std::string m_errMsg;
@@ -68,6 +72,16 @@
      */
     explicit EccException(const std::string& msg) : Exception(msg) {}
 
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * EccException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::EccCheckFailed;
+    }
+
 }; // class EccException
 
 /** @class DataException
@@ -93,6 +107,15 @@
      */
     explicit DataException(const std::string& msg) : Exception(msg) {}
 
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * DataException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::InvalidVpdMessage;
+    }
 }; // class DataException
 
 class JsonException : public Exception
@@ -124,6 +147,16 @@
         return m_jsonPath;
     }
 
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * JsonException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::JsonFailure;
+    }
+
   private:
     /** To hold the path of Json that failed*/
     std::string m_jsonPath;
@@ -152,6 +185,16 @@
      *  @param[in] msg - string to define exception
      */
     explicit GpioException(const std::string& msg) : Exception(msg) {}
+
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * GpioException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::GpioError;
+    }
 };
 
 /** @class DbusException
@@ -176,6 +219,16 @@
      *  @param[in] msg - string to define exception
      */
     explicit DbusException(const std::string& msg) : Exception(msg) {}
+
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * DbusException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::DbusFailure;
+    }
 };
 
 /** @class FirmwareException
@@ -200,6 +253,16 @@
      *  @param[in] msg - string to define exception
      */
     explicit FirmwareException(const std::string& msg) : Exception(msg) {}
+
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * FirmwareException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::InternalFailure;
+    }
 };
 
 /** @class EepromException
@@ -224,6 +287,16 @@
      *  @param[in] msg - string to define exception
      */
     explicit EepromException(const std::string& msg) : Exception(msg) {}
+
+    /** @brief Method to get error type
+     *
+     * @return Error type which has to be logged for errors of type
+     * EepromException.
+     */
+    types::ErrorType getErrorType() const
+    {
+        return types::ErrorType::InvalidEeprom;
+    }
 };
 
 } // namespace vpd