From 3c5fb017bf86392739258964aa54708f34d4b804 Mon Sep 17 00:00:00 2001 From: ywsung Date: Thu, 15 Jan 2015 16:30:54 +0900 Subject: [PATCH] Add missing enum value of OCStackResult to switch in reason() function of OCException class - Adding missing case of enum value (OC_STACK_REPEATED_REQUEST, OC_STACK_INVALID_DEVICE_INFO) to switch statement - Adding constant strings to StringContant.h - Reorder case statements by OCStackResult definition order Change-Id: I207a2f9122779c37df48aae260061fce442de798 Signed-off-by: ywsung --- resource/include/StringConstants.h | 2 ++ resource/src/OCException.cpp | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/resource/include/StringConstants.h b/resource/include/StringConstants.h index 57a9236..a27fcd8 100644 --- a/resource/include/StringConstants.h +++ b/resource/include/StringConstants.h @@ -79,6 +79,7 @@ namespace OC static const char NOT_FOUND[] = "Resource Not Found"; static const char RESOURCE_ERROR[] = "Resource Error"; static const char SLOW_RESOURCE[] = "Slow Resource"; + static const char REPEATED_REQUEST[] = "Repeated Request"; static const char NO_OBSERVERS[] = "No Observers"; static const char OBSV_NO_FOUND[] = "Stack observer not found"; static const char OBSV_NOT_ADDED[] = "Stack observer not added"; @@ -94,6 +95,7 @@ namespace OC static const char PERSISTENT_BUFFER_REQUIRED[] = "Persistent response buffer required"; static const char STACK_CONTINUE[] = "Stack continue"; static const char INVALID_REQUEST_HANDLE[] = "Invalid request handle"; + static const char INVALID_DEVICE_INFO[] = "Invalid device info"; static const char UNKNOWN_ERROR[] = "Unknown Error"; static const char INVALID_REPRESENTATION[] = "Invalid Payload JSON"; static const char INVALID_JSON_TYPE[] = "Unrecognized JSON Type "; diff --git a/resource/src/OCException.cpp b/resource/src/OCException.cpp index 9bea2e2..eb2b201 100644 --- a/resource/src/OCException.cpp +++ b/resource/src/OCException.cpp @@ -31,8 +31,12 @@ std::string OC::OCException::reason(const OCStackResult sr) return OC::Exception::RESOURCE_CREATED; case OC_STACK_RESOURCE_DELETED: return OC::Exception::RESOURCE_DELETED; + case OC_STACK_CONTINUE: + return OC::Exception::STACK_CONTINUE; case OC_STACK_INVALID_URI: return OC::Exception::INVALID_URI; + case OC_STACK_INVALID_QUERY: + return OC::Exception::INVALID_QUERY; case OC_STACK_INVALID_IP: return OC::Exception::INVALID_IP; case OC_STACK_INVALID_PORT: @@ -41,8 +45,6 @@ std::string OC::OCException::reason(const OCStackResult sr) return OC::Exception::INVALID_CB; case OC_STACK_INVALID_METHOD: return OC::Exception::INVALID_METHOD; - case OC_STACK_INVALID_QUERY: - return OC::Exception::INVALID_QUERY; case OC_STACK_INVALID_PARAM: return OC::Exception::INVALID_PARAM; case OC_STACK_INVALID_OBSERVE_PARAM: @@ -59,18 +61,12 @@ std::string OC::OCException::reason(const OCStackResult sr) return OC::Exception::RESOURCE_ERROR; case OC_STACK_SLOW_RESOURCE: return OC::Exception::SLOW_RESOURCE; + case OC_STACK_REPEATED_REQUEST: + return OC::Exception::REPEATED_REQUEST; case OC_STACK_NO_OBSERVERS: return OC::Exception::NO_OBSERVERS; case OC_STACK_OBSERVER_NOT_FOUND: return OC::Exception::OBSV_NO_FOUND; -#ifdef WITH_PRESENCE - case OC_STACK_PRESENCE_STOPPED: - return OC::Exception::PRESENCE_STOPPED; - case OC_STACK_PRESENCE_TIMEOUT: - return OC::Exception::PRESENCE_TIMEOUT; - case OC_STACK_PRESENCE_DO_NOT_HANDLE: - return OC::Exception::PRESENCE_NOT_HANDLED; -#endif case OC_STACK_VIRTUAL_DO_NOT_HANDLE: return OC::Exception::VIRTUAL_DO_NOT_HANDLE; case OC_STACK_INVALID_OPTION: @@ -79,10 +75,18 @@ std::string OC::OCException::reason(const OCStackResult sr) return OC::Exception::MALFORMED_STACK_RESPONSE; case OC_STACK_PERSISTENT_BUFFER_REQUIRED: return OC::Exception::PERSISTENT_BUFFER_REQUIRED; - case OC_STACK_CONTINUE: - return OC::Exception::STACK_CONTINUE; case OC_STACK_INVALID_REQUEST_HANDLE: return OC::Exception::INVALID_REQUEST_HANDLE; + case OC_STACK_INVALID_DEVICE_INFO: + return OC::Exception::INVALID_DEVICE_INFO; +#ifdef WITH_PRESENCE + case OC_STACK_PRESENCE_STOPPED: + return OC::Exception::PRESENCE_STOPPED; + case OC_STACK_PRESENCE_TIMEOUT: + return OC::Exception::PRESENCE_TIMEOUT; + case OC_STACK_PRESENCE_DO_NOT_HANDLE: + return OC::Exception::PRESENCE_NOT_HANDLED; +#endif case OC_STACK_ERROR: return OC::Exception::GENERAL_FAULT; } -- 2.7.4