Added some string constants to cover exception cases
authorErich Keane <erich.keane@intel.com>
Thu, 23 Oct 2014 17:40:37 +0000 (10:40 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 23 Oct 2014 17:40:37 +0000 (10:40 -0700)
Change-Id: I102a7b136b6cc2d5c309e8c7984869aa51594e80

include/OCApi.h
include/OCHeaderOption.h
include/OCUtilities.h
include/StringConstants.h
src/InProcServerWrapper.cpp

index 30f9e4a..81a42bd 100644 (file)
@@ -314,7 +314,7 @@ namespace OC
         }
         catch(boost::property_tree::json_parser::json_parser_error &e)
         {
-            throw OCException("JSON parse error");
+            throw OCException(GENERAL_JSON_PARSE_FAILED);
         }
 
         for(auto& item: payload)
index 73993f3..1d791c0 100644 (file)
@@ -60,7 +60,7 @@ namespace OC
             {
                 if(!(optionID >= MIN_HEADER_OPTIONID && optionID <= MAX_HEADER_OPTIONID))
                 {
-                    throw OCException("Error:OptionID valid only from 2048 to 3000 inclusive");
+                    throw OCException(OC::Exception::OPTION_ID_RANGE_INVALID);
                 }
             }
 
index 35a6383..a736820 100644 (file)
@@ -81,7 +81,7 @@ namespace OC {
     {
         if(nullptr == p)
         {
-            throw OCException("nullptr at nil_guard()", OC_STACK_INVALID_PARAM);
+            throw OCException(OC::Exception::NIL_GUARD_NULL, OC_STACK_INVALID_PARAM);
         }
 
         // Note that although parameters are being forwarded, std::bind() will make a single copy:
index 24c985f..1892efd 100644 (file)
@@ -58,7 +58,11 @@ namespace OC
         static const std::string INVALID_ARRAY              = "Array type should have at least []";
         static const std::string STR_NULL_RESPONSE          = "Response is NULL";
         static const std::string STR_PAYLOAD_OVERFLOW       = "Payload overflow";
-
+        static const std::string NIL_GUARD_NULL             = "nullptr at nil_guard()";
+        static const std::string GENERAL_JSON_PARSE_FAILED  = "JSON Parser Error";
+        static const std::string RESOURCE_UNREG_FAILED      = "Unregistering resource failed";
+        static const std::string OPTION_ID_RANGE_INVALID    =
+                            "Error: OptionID valid only from 2048 to 3000 inclusive.";
 
         static const std::string NO_ERROR                   = "No Error";
         static const std::string RESOURCE_CREATED           = "Resource Created";
@@ -88,6 +92,7 @@ namespace OC
         static const std::string GENERAL_FAULT              = "General Fault";
         static const std::string MALFORMED_STACK_RESPONSE   = "Response from OC_STACK is malformed";
         static const std::string UNKNOWN_ERROR              = "Unknown Error";
+
     }
 
     namespace Error
index 43c9a77..f1f8214 100644 (file)
@@ -89,7 +89,6 @@ void formResourceRequest(OCEntityHandlerFlag flag,
 
             if(OC_REST_GET == entityHandlerRequest->method)
             {
-                // TODO Why strings : "GET"??
                 pRequest->setRequestType(OC::PlatformCommands::GET);
             }
             else if(OC_REST_PUT == entityHandlerRequest->method)
@@ -106,7 +105,7 @@ void formResourceRequest(OCEntityHandlerFlag flag,
             }
             else if(OC_REST_DELETE == entityHandlerRequest->method)
             {
-                pRequest->setRequestType("DELETE");
+                pRequest->setRequestType(OC::PlatformCommands::DELETE);
             }
         }
     }
@@ -423,7 +422,7 @@ namespace OC
             }
             else
             {
-                throw OCException("Unregistering resource failed", result);
+                throw OCException(OC::Exception::RESOURCE_UNREG_FAILED, result);
             }
         }
         else