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 30f9e4ab102bb012186b1437d18194d423e1cc24..81a42bd5c5152168edae3d1122901c53a4448ce2 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 73993f30f72568f0faa171f86c084433356f7d1c..1d791c05fce66769a1ad848ed306511f3477deeb 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 35a6383fade6c5c03f9c105337db356ad6d38215..a7368207deefae5975611dee09bd4d2f416ad596 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 24c985f853d266906d17714ea02ce9d3af0af2f2..1892efd3ed97df2ebd878856fec39a23baab638f 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 43c9a7757ca044ee7cb0302f5681365f8b37d0d2..f1f8214c89c31e1fa18fee68200cc8d6efab41f4 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