Fixed InitializeException issues
authorErich Keane <erich.keane@intel.com>
Mon, 16 Mar 2015 20:38:00 +0000 (13:38 -0700)
committerSashi Penta <sashi.kumar.penta@intel.com>
Wed, 18 Mar 2015 23:27:27 +0000 (23:27 +0000)
InitializeException had a number of minor issues that are repaired in
this fix.  Note that the interface of InitializeException changes a bit,
however it seems that no one is actually catching InitializeException
anywhere, so they wouldn't be able to use the old version.

This fix switches InitializeException to inherit from OCException,
permitting us to catch it properly, rather than being a different exception
type.  This results in the reason, code, and 'what' methods working properly
in both cases, rather than differing slightly by behavior.

Change-Id: If41377af1b1c4ef7297ae9644ef2e7e7e4f8b603
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/483
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/include/InitializeException.h

index c6eed56..f87972f 100644 (file)
 
 namespace OC
 {
-    class InitializeException : public std::exception
+    class InitializeException : public OC::OCException
     {
     public:
-        InitializeException(const std::string& msg, OCStackResult reasonCode): m_errorMessage(msg), m_reason(reasonCode)
+        InitializeException(const std::string& msg, OCStackResult reasonCode):
+            OC::OCException(msg, reasonCode)
         {
         }
-
-        OCStackResult ReasonCode()
-        {
-            return m_reason;
-        }
-
-        std::string Message()
-        {
-            return m_errorMessage;
-        }
-
-        std::string Reason()
-        {
-            switch(m_reason)
-            {
-            case OC_STACK_OK:
-                return OC::InitException::NO_ERROR;
-            case OC_STACK_INVALID_URI:
-                return OC::InitException::INVALID_URI;
-            case OC_STACK_INVALID_IP:
-                return OC::InitException::INVALID_IP;
-            case OC_STACK_INVALID_PORT:
-                return OC::InitException::INVALID_PORT;
-            case OC_STACK_INVALID_CALLBACK:
-                return OC::InitException::INVALID_CB;
-            case OC_STACK_INVALID_METHOD:
-                return OC::InitException::INVALID_METHOD;
-            case OC_STACK_ERROR:
-                return OC::InitException::GENERAL_FAULT;
-            default:
-                return OC::InitException::UNKNOWN_ERROR;
-            }
-        }
-
-    private:
-        const std::string& m_errorMessage;
-        OCStackResult m_reason;
     };
 }