diff OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 5011:c014ab79fca5

fixed /move documentation + improved error reporting
author Alain Mazy <am@osimis.io>
date Tue, 31 May 2022 09:36:00 +0200
parents d0c34145320c
children 6fed78e13233
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon May 30 09:08:54 2022 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Tue May 31 09:36:00 2022 +0200
@@ -2296,11 +2296,19 @@
 
 
   void FromDcmtkBridge::FromJson(DicomMap& target,
-                                 const Json::Value& source)
+                                 const Json::Value& source,
+                                 const char* fieldName)
   {
     if (source.type() != Json::objectValue)
     {
-      throw OrthancException(ErrorCode_BadFileFormat);
+      if (fieldName != NULL) 
+      {
+        throw OrthancException(ErrorCode_BadFileFormat, std::string("Expecting an object in field '") + std::string(fieldName) + std::string("'"));
+      }
+      else
+      {
+        throw OrthancException(ErrorCode_BadFileFormat, "Expecting an object");
+      }
     }
 
     target.Clear();
@@ -2313,7 +2321,7 @@
 
       if (value.type() != Json::stringValue)
       {
-        throw OrthancException(ErrorCode_BadFileFormat);
+        throw OrthancException(ErrorCode_BadFileFormat, std::string("Expecting a string in field '") + members[i] + std::string("'"));
       }
       
       target.SetValue(ParseTag(members[i]), value.asString(), false);
@@ -2321,6 +2329,8 @@
   }
 
 
+
+
   void FromDcmtkBridge::ChangeStringEncoding(DcmItem& dataset,
                                              Encoding source,
                                              bool hasSourceCodeExtensions,