Add logs to where exceptions are swallowed
authorcoderhyme <jhyo.kim@samsung.com>
Tue, 23 Jun 2015 08:13:39 +0000 (17:13 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 23 Jun 2015 10:41:46 +0000 (10:41 +0000)
Change-Id: Iacd2b4fcab6f2bf453c32264b853ad410e221900
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1396
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/basis/serverBuilder/src/PrimitiveServerResource.cpp

index dc43b3b..1201468 100644 (file)
 #include <internal/RequestHandler.h>
 #include <internal/AssertUtils.h>
 
+
+#include <logger.h>
 #include <OCPlatform.h>
 
 namespace
 {
     using namespace OIC::Service;
 
+    constexpr const char LOG_TAG[]{ "PrimitiveServerResource" };
+
     namespace Detail
     {
         template <typename RESPONSE>
@@ -45,10 +49,18 @@ namespace
             ocResponse->setRequestHandle(ocRequest->getRequestHandle());
             ocResponse->setResourceHandle(ocRequest->getResourceHandle());
 
-            if (OC::OCPlatform::sendResponse(ocResponse) == OC_STACK_OK)
+            try
+            {
+                if (OC::OCPlatform::sendResponse(ocResponse) == OC_STACK_OK)
+                {
+                    return OC_EH_OK;
+                }
+            }
+            catch (const OC::OCException& e)
             {
-                return OC_EH_OK;
+                OC_LOG(WARNING, LOG_TAG, e.what());
             }
+
             return OC_EH_ERROR;
         }
     }
@@ -169,6 +181,7 @@ namespace OIC
                 }
                 catch (...)
                 {
+                    OC_LOG(WARNING, LOG_TAG, "Failed to unregister resource.");
                 }
             }
         }
@@ -246,6 +259,7 @@ namespace OIC
             }
             catch (...)
             {
+                OC_LOG(WARNING, LOG_TAG, "Failed to handle request.");
                 // TODO : how to notify the error?
             }