diff Core/WebServiceParameters.cpp @ 2954:d924f9bb61cc

taking advantage of details in OrthancException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Dec 2018 14:35:34 +0100
parents 807169f85ba9
children 4e43e67f8ecf
line wrap: on
line diff
--- a/Core/WebServiceParameters.cpp	Mon Dec 03 11:49:39 2018 +0100
+++ b/Core/WebServiceParameters.cpp	Mon Dec 03 14:35:34 2018 +0100
@@ -92,8 +92,7 @@
     if (!Toolbox::StartsWith(url, "http://") &&
         !Toolbox::StartsWith(url, "https://"))
     {
-      LOG(ERROR) << "Bad URL: " << url;
-      throw OrthancException(ErrorCode_BadFileFormat);
+      throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url);
     }
 
     // Add trailing slash if needed
@@ -142,8 +141,9 @@
 
     if (certificateKeyPassword.empty())
     {
-      LOG(ERROR) << "The password for the HTTPS certificate is not provided: " << certificateFile;
-      throw OrthancException(ErrorCode_BadFileFormat);      
+      throw OrthancException(
+        ErrorCode_BadFileFormat,
+        "The password for the HTTPS certificate is not provided: " + certificateFile);
     }
 
     certificateFile_ = certificateFile;
@@ -173,8 +173,8 @@
     }
     else if (peer.size() == 2)
     {
-      LOG(ERROR) << "The HTTP password is not provided";
-      throw OrthancException(ErrorCode_BadFileFormat);
+      throw OrthancException(ErrorCode_BadFileFormat,
+                             "The HTTP password is not provided");
     }
     else if (peer.size() == 3)
     {
@@ -364,8 +364,9 @@
   {
     if (IsReservedKey(key))
     {
-      LOG(ERROR) << "Cannot use this reserved key to name an user property: " << key;
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw OrthancException(
+        ErrorCode_ParameterOutOfRange,
+        "Cannot use this reserved key to name an user property: " + key);
     }
     else
     {
@@ -488,15 +489,15 @@
     {
       if (!SystemToolbox::IsRegularFile(certificateFile_))
       {
-        LOG(ERROR) << "Cannot open certificate file: " << certificateFile_;
-        throw OrthancException(ErrorCode_InexistentFile);
+        throw OrthancException(ErrorCode_InexistentFile,
+                               "Cannot open certificate file: " + certificateFile_);
       }
 
       if (!certificateKeyFile_.empty() && 
           !SystemToolbox::IsRegularFile(certificateKeyFile_))
       {
-        LOG(ERROR) << "Cannot open key file: " << certificateKeyFile_;
-        throw OrthancException(ErrorCode_InexistentFile);
+        throw OrthancException(ErrorCode_InexistentFile,
+                               "Cannot open key file: " + certificateKeyFile_);
       }
     }
   }