Custom Exception type for openpower-vpd-parser.

This commit implements custom exception type for openpower-vpd-parser
repo.
With this runtime exceptions can be classified into categories and
appropriate actions can be taken based on their type.

Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: Ia514141e9166a76ba43c536a2e0f1229bd544bae
diff --git a/vpd_exceptions.hpp b/vpd_exceptions.hpp
new file mode 100644
index 0000000..35c05d4
--- /dev/null
+++ b/vpd_exceptions.hpp
@@ -0,0 +1,135 @@
+#pragma once
+
+#include <stdexcept>
+
+namespace openpower
+{
+namespace vpd
+{
+namespace exceptions
+{
+
+/** @class VPDException
+ * @brief This class inherits std::runtime_error and overrrides
+ * "what" method to return the description of exception.
+ * This class also works as base class for custom exception
+ * classes of openpower-vpd repository.
+ */
+class VPDException : public std::runtime_error
+{
+  public:
+    // deleted methods
+    VPDException() = delete;
+    VPDException(const VPDException&) = delete;
+    VPDException(VPDException&&) = delete;
+    VPDException& operator=(const VPDException&) = delete;
+
+    // default destructor
+    ~VPDException() = default;
+
+    /** @brief constructor
+     *  @param[in] - string to define exception
+     */
+    explicit VPDException(const std::string& msg) :
+        std::runtime_error(msg), errMsg(msg)
+    {
+    }
+
+    /** @brief inline method to return exception string
+     * This is overridden method of std::runtime class
+     */
+    inline const char* what() const noexcept override
+    {
+        return errMsg.c_str();
+    }
+
+  private:
+    /** @brief string to hold the reason of exception */
+    std::string errMsg;
+
+}; // class VPDException
+
+/** @class VpdEccException
+ *  @brief This class extends Exceptions class and define
+ *  type for ECC related exception in VPD
+ */
+class VpdEccException : public VPDException
+{
+  public:
+    // deleted methods
+    VpdEccException() = delete;
+    VpdEccException(const VpdEccException&) = delete;
+    VpdEccException(VpdEccException&&) = delete;
+    VpdEccException& operator=(const VpdEccException&) = delete;
+
+    // default destructor
+    ~VpdEccException() = default;
+
+    /** @brief constructor
+     *  @param[in] - string to define exception
+     */
+    explicit VpdEccException(const std::string& msg) : VPDException(msg)
+    {
+    }
+
+}; // class VpdEccException
+
+/** @class VpdDataException
+ *  @brief This class extends Exceptions class and define
+ *  type for data related exception in VPD
+ */
+class VpdDataException : public VPDException
+{
+  public:
+    // deleted methods
+    VpdDataException() = delete;
+    VpdDataException(const VpdDataException&) = delete;
+    VpdDataException(VpdDataException&&) = delete;
+    VpdDataException& operator=(const VpdDataException&) = delete;
+
+    // default destructor
+    ~VpdDataException() = default;
+
+    /** @brief constructor
+     *  @param[in] - string to define exception
+     */
+    explicit VpdDataException(const std::string& msg) : VPDException(msg)
+    {
+    }
+
+}; // class VpdDataException
+
+class VpdJsonException : public VPDException
+{
+  public:
+    // deleted methods
+    VpdJsonException() = delete;
+    VpdJsonException(const VpdJsonException&) = delete;
+    VpdJsonException(VpdDataException&&) = delete;
+    VpdJsonException& operator=(const VpdDataException&) = delete;
+
+    // default destructor
+    ~VpdJsonException() = default;
+
+    /** @brief constructor
+     *  @param[in] - string to define exception
+     */
+    explicit VpdJsonException(const std::string& msg, const std::string& Path) :
+        VPDException(msg), jsonPath(Path)
+    {
+    }
+
+    inline std::string getJsonPath() const
+    {
+        return jsonPath;
+    }
+
+  private:
+    /** To hold the path of Json that failed to parse*/
+    std::string jsonPath;
+
+}; // class VpdJSonException
+
+} // namespace exceptions
+} // namespace vpd
+} // namespace openpower
\ No newline at end of file