diff OrthancServer/OrthancInitialization.cpp @ 1592:d73124f6b439

configuration option HttpDescribeErrors
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Aug 2015 11:35:16 +0200
parents d7e569640d09
children f2e3d030ea59
line wrap: on
line diff
--- a/OrthancServer/OrthancInitialization.cpp	Thu Aug 27 10:54:52 2015 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Thu Aug 27 11:35:16 2015 +0200
@@ -82,7 +82,15 @@
   {
     if (configuration_.isMember(parameter))
     {
-      return configuration_[parameter].asString();
+      if (configuration_[parameter].type() != Json::stringValue)
+      {
+        LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string";
+        throw OrthancException(ErrorCode_BadParameterType);
+      }
+      else
+      {
+        return configuration_[parameter].asString();
+      }
     }
     else
     {
@@ -96,7 +104,15 @@
   {
     if (configuration_.isMember(parameter))
     {
-      return configuration_[parameter].asBool();
+      if (configuration_[parameter].type() != Json::booleanValue)
+      {
+        LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a Boolean (true or false)";
+        throw OrthancException(ErrorCode_BadParameterType);
+      }
+      else
+      {
+        return configuration_[parameter].asBool();
+      }
     }
     else
     {
@@ -382,7 +398,15 @@
 
     if (configuration_.isMember(parameter))
     {
-      return configuration_[parameter].asInt();
+      if (configuration_[parameter].type() != Json::intValue)
+      {
+        LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer";
+        throw OrthancException(ErrorCode_BadParameterType);
+      }
+      else
+      {
+        return configuration_[parameter].asInt();
+      }
     }
     else
     {