# HG changeset patch # User Sebastien Jodogne # Date 1435155463 -7200 # Node ID 52b2070fc8f1f28dda9bfbfa5d4dd649acea1270 # Parent d401287210d30c8919b4b2f7db579f5375a10a48 improvements to the logs diff -r d401287210d3 -r 52b2070fc8f1 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Tue Jun 23 11:48:04 2015 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Wed Jun 24 16:17:43 2015 +0200 @@ -113,7 +113,8 @@ Json::Reader reader; if (!reader.parse(content, *configuration_)) { - throw OrthancException("Unable to read the configuration file"); + LOG(ERROR) << "Unable to read the configuration file"; + throw OrthancException(ErrorCode_BadFileFormat); } } @@ -291,12 +292,14 @@ if (configuration_.get() == NULL) { + LOG(ERROR) << "The configuration file was not properly loaded"; throw OrthancException(ErrorCode_InexistentItem); } if (!configuration_->isMember("DicomModalities")) { - throw OrthancException(ErrorCode_BadFileFormat); + LOG(ERROR) << "No modality with symbolic name: " << name; + throw OrthancException(ErrorCode_InexistentItem); } const Json::Value& modalities = (*configuration_) ["DicomModalities"]; @@ -328,12 +331,14 @@ if (configuration_.get() == NULL) { + LOG(ERROR) << "The configuration file was not properly loaded"; throw OrthancException(ErrorCode_InexistentItem); } if (!configuration_->isMember("OrthancPeers")) { - throw OrthancException(ErrorCode_BadFileFormat); + LOG(ERROR) << "No peer with symbolic name: " << name; + throw OrthancException(ErrorCode_InexistentItem); } try @@ -374,6 +379,7 @@ const Json::Value& modalities = (*configuration_) [parameter]; if (modalities.type() != Json::objectValue) { + LOG(ERROR) << "Bad format of the \"DicomModalities\" configuration section"; throw OrthancException(ErrorCode_BadFileFormat); } @@ -402,7 +408,8 @@ { if (!ReadKeys(target, "DicomModalities", true)) { - throw OrthancException("Only alphanumeric and dash characters are allowed in the names of the modalities"); + LOG(ERROR) << "Only alphanumeric and dash characters are allowed in the names of the modalities"; + throw OrthancException(ErrorCode_BadFileFormat); } } @@ -411,7 +418,8 @@ { if (!ReadKeys(target, "OrthancPeers", true)) { - throw OrthancException("Only alphanumeric and dash characters are allowed in the names of Orthanc peers"); + LOG(ERROR) << "Only alphanumeric and dash characters are allowed in the names of Orthanc peers"; + throw OrthancException(ErrorCode_BadFileFormat); } } @@ -432,7 +440,8 @@ const Json::Value& users = (*configuration_) ["RegisteredUsers"]; if (users.type() != Json::objectValue) { - throw OrthancException("Badly formatted list of users"); + LOG(ERROR) << "Badly formatted list of users"; + throw OrthancException(ErrorCode_BadFileFormat); } Json::Value::Members usernames = users.getMemberNames(); @@ -495,7 +504,8 @@ if (lst.type() != Json::arrayValue) { - throw OrthancException("Badly formatted list of strings"); + LOG(ERROR) << "Badly formatted list of strings"; + throw OrthancException(ErrorCode_BadFileFormat); } for (Json::Value::ArrayIndex i = 0; i < lst.size(); i++) @@ -577,7 +587,8 @@ } else { - throw OrthancException("Unknown modality for AET: " + aet); + LOG(ERROR) << "Unknown modality for AET: " << aet; + throw OrthancException(ErrorCode_InexistentItem); } } @@ -589,6 +600,7 @@ if (configuration_.get() == NULL) { + LOG(ERROR) << "The configuration file was not properly loaded"; throw OrthancException(ErrorCode_InternalError); } @@ -600,6 +612,7 @@ Json::Value& modalities = (*configuration_) ["DicomModalities"]; if (modalities.type() != Json::objectValue) { + LOG(ERROR) << "Bad file format for modality: " << symbolicName; throw OrthancException(ErrorCode_BadFileFormat); } @@ -617,17 +630,20 @@ if (configuration_.get() == NULL) { + LOG(ERROR) << "The configuration file was not properly loaded"; throw OrthancException(ErrorCode_InternalError); } if (!configuration_->isMember("DicomModalities")) { + LOG(ERROR) << "No modality with symbolic name: " << symbolicName; throw OrthancException(ErrorCode_BadFileFormat); } Json::Value& modalities = (*configuration_) ["DicomModalities"]; if (modalities.type() != Json::objectValue) { + LOG(ERROR) << "Bad file format for the \"DicomModalities\" configuration section"; throw OrthancException(ErrorCode_BadFileFormat); } @@ -642,17 +658,20 @@ if (configuration_.get() == NULL) { + LOG(ERROR) << "The configuration file was not properly loaded"; throw OrthancException(ErrorCode_InternalError); } if (!configuration_->isMember("OrthancPeers")) { + LOG(ERROR) << "No peer with symbolic name: " << symbolicName; (*configuration_) ["OrthancPeers"] = Json::objectValue; } Json::Value& peers = (*configuration_) ["OrthancPeers"]; if (peers.type() != Json::objectValue) { + LOG(ERROR) << "Bad file format for the \"OrthancPeers\" configuration section"; throw OrthancException(ErrorCode_BadFileFormat); } @@ -670,17 +689,20 @@ if (configuration_.get() == NULL) { + LOG(ERROR) << "The configuration file was not properly loaded"; throw OrthancException(ErrorCode_InternalError); } if (!configuration_->isMember("OrthancPeers")) { + LOG(ERROR) << "No peer with symbolic name: " << symbolicName; throw OrthancException(ErrorCode_BadFileFormat); } Json::Value& peers = (*configuration_) ["OrthancPeers"]; if (peers.type() != Json::objectValue) { + LOG(ERROR) << "Bad file format for the \"OrthancPeers\" configuration section"; throw OrthancException(ErrorCode_BadFileFormat); }