Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1591:cd9d99fe32e9 | 1592:d73124f6b439 |
---|---|
80 static std::string GetGlobalStringParameterInternal(const std::string& parameter, | 80 static std::string GetGlobalStringParameterInternal(const std::string& parameter, |
81 const std::string& defaultValue) | 81 const std::string& defaultValue) |
82 { | 82 { |
83 if (configuration_.isMember(parameter)) | 83 if (configuration_.isMember(parameter)) |
84 { | 84 { |
85 return configuration_[parameter].asString(); | 85 if (configuration_[parameter].type() != Json::stringValue) |
86 { | |
87 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string"; | |
88 throw OrthancException(ErrorCode_BadParameterType); | |
89 } | |
90 else | |
91 { | |
92 return configuration_[parameter].asString(); | |
93 } | |
86 } | 94 } |
87 else | 95 else |
88 { | 96 { |
89 return defaultValue; | 97 return defaultValue; |
90 } | 98 } |
94 static bool GetGlobalBoolParameterInternal(const std::string& parameter, | 102 static bool GetGlobalBoolParameterInternal(const std::string& parameter, |
95 bool defaultValue) | 103 bool defaultValue) |
96 { | 104 { |
97 if (configuration_.isMember(parameter)) | 105 if (configuration_.isMember(parameter)) |
98 { | 106 { |
99 return configuration_[parameter].asBool(); | 107 if (configuration_[parameter].type() != Json::booleanValue) |
108 { | |
109 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a Boolean (true or false)"; | |
110 throw OrthancException(ErrorCode_BadParameterType); | |
111 } | |
112 else | |
113 { | |
114 return configuration_[parameter].asBool(); | |
115 } | |
100 } | 116 } |
101 else | 117 else |
102 { | 118 { |
103 return defaultValue; | 119 return defaultValue; |
104 } | 120 } |
380 { | 396 { |
381 boost::mutex::scoped_lock lock(globalMutex_); | 397 boost::mutex::scoped_lock lock(globalMutex_); |
382 | 398 |
383 if (configuration_.isMember(parameter)) | 399 if (configuration_.isMember(parameter)) |
384 { | 400 { |
385 return configuration_[parameter].asInt(); | 401 if (configuration_[parameter].type() != Json::intValue) |
402 { | |
403 LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer"; | |
404 throw OrthancException(ErrorCode_BadParameterType); | |
405 } | |
406 else | |
407 { | |
408 return configuration_[parameter].asInt(); | |
409 } | |
386 } | 410 } |
387 else | 411 else |
388 { | 412 { |
389 return defaultValue; | 413 return defaultValue; |
390 } | 414 } |