diff Plugins/Samples/ServeFolders/Plugin.cpp @ 2234:a78d15509a1c

cleaner separation of PluginException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Dec 2016 14:35:35 +0100
parents 395522e46b2b
children a3a65de1840f
line wrap: on
line diff
--- a/Plugins/Samples/ServeFolders/Plugin.cpp	Wed Dec 14 16:57:21 2016 +0100
+++ b/Plugins/Samples/ServeFolders/Plugin.cpp	Fri Dec 16 14:35:35 2016 +0100
@@ -204,7 +204,7 @@
       }
       catch (...)
       {
-        ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InexistentFile);
+        ORTHANC_PLUGINS_THROW_EXCEPTION(InexistentFile);
       }
 
       boost::posix_time::ptime lastModification = boost::posix_time::from_time_t(fs::last_write_time(path));
@@ -257,7 +257,7 @@
   if (folders.type() != Json::objectValue)
   {
     OrthancPlugins::LogError(context_, "The list of folders to be served is badly formatted (must be a JSON object)");
-    ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat);
+    ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
   }
 
   Json::Value::Members members = folders.getMemberNames();
@@ -270,7 +270,7 @@
     {
       OrthancPlugins::LogError(context_, "The folder to be served \"" + *it + 
                                "\" must be associated with a string value (its mapped URI)");
-      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat);
+      ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
 
     std::string baseUri = *it;
@@ -291,7 +291,7 @@
     if (baseUri.empty())
     {
       OrthancPlugins::LogError(context_, "The URI of a folder to be served cannot be empty");
-      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat);
+      ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
 
     // Check whether the source folder exists and is indeed a directory
@@ -299,7 +299,7 @@
     if (!boost::filesystem::is_directory(folder))
     {
       OrthancPlugins::LogError(context_, "Trying and serve an inexistent folder: " + folder);
-      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InexistentFile);
+      ORTHANC_PLUGINS_THROW_EXCEPTION(InexistentFile);
     }
 
     folders_[baseUri] = folder;
@@ -318,7 +318,7 @@
   if (extensions.type() != Json::objectValue)
   {
     OrthancPlugins::LogError(context_, "The list of extensions is badly formatted (must be a JSON object)");
-    ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat);
+    ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
   }
 
   Json::Value::Members members = extensions.getMemberNames();
@@ -330,7 +330,7 @@
     {
       OrthancPlugins::LogError(context_, "The file extension \"" + *it + 
                                "\" must be associated with a string value (its MIME type)");
-      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat);
+      ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
 
     const std::string& mime = extensions[*it].asString();