diff Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2973:9b734c3e1095

more defensive parsing of responses
author am@osimis.io
date Thu, 06 Dec 2018 10:39:08 +0100
parents e361df74639f
children 5947aeedf41f
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Dec 05 16:30:28 2018 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Thu Dec 06 10:39:08 2018 +0100
@@ -1152,7 +1152,10 @@
     }
     else
     {
-      answer.ToJson(result);
+      if (!answer.IsEmpty())
+      {
+        answer.ToJson(result);
+      }
       return true;
     }
   }
@@ -1172,7 +1175,10 @@
     }
     else
     {
-      answer.ToJson(result);
+      if (!answer.IsEmpty())
+      {
+        answer.ToJson(result);
+      }
       return true;
     }
   }
@@ -1202,7 +1208,10 @@
     }
     else
     {
-      answer.ToJson(result);
+      if (!answer.IsEmpty()) // i.e, on a PUT to metadata/..., orthand returns an empty response
+      {
+        answer.ToJson(result);
+      }
       return true;
     }
   }