replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / resource-encapsulation / examples / linux / SeparateResponseServer.cpp
index 9edf591..1a76655 100755 (executable)
@@ -45,7 +45,10 @@ void handleRequestWithDelay(int delayInMillis, const RCSRequest& request,
         auto& resAttrs = resObject->getAttributes();
         for (const auto& kv : requestedAttrs)
         {
-            if (resAttrs.contains(kv.key())) resAttrs[kv.key()] = kv.value();
+            if (resAttrs.contains(kv.key()))
+            {
+                resAttrs[kv.key()] = kv.value();
+            }
         }
     }
 
@@ -67,7 +70,7 @@ int processUserInput(int min, int max)
 {
     assert(min <= max);
 
-    int input;
+    int input = 0;
 
     while(true)
     {
@@ -75,7 +78,10 @@ int processUserInput(int min, int max)
 
         if (!std::cin.fail())
         {
-            if(min <= input && input <= max) return input;
+            if(min <= input && input <= max)
+            {
+                return input;
+            }
         }
 
         std::cin.clear();
@@ -145,7 +151,15 @@ void selectResourceType()
 
 int main(void)
 {
-    selectResourceType();
+    try
+    {
+        selectResourceType();
+    }
+    catch(...)
+    {
+        std::cout << "Can't select Resource Type" << std::endl;
+        return -1;
+    }
 
     std::cout << "Resource successfully created!" << std::endl;