diff Plugins/Engine/PluginsErrorDictionary.cpp @ 1650:9f34ebfaf2c9

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Sep 2015 16:47:05 +0200
parents 8040d56cb0b3
children 2e692c83e2f3
line wrap: on
line diff
--- a/Plugins/Engine/PluginsErrorDictionary.cpp	Fri Sep 25 16:24:13 2015 +0200
+++ b/Plugins/Engine/PluginsErrorDictionary.cpp	Fri Sep 25 16:47:05 2015 +0200
@@ -41,6 +41,7 @@
 
 #include "PluginsEnumerations.h"
 #include "PluginsManager.h"
+#include "../../Core/Logging.h"
 
 #include <memory>
 
@@ -87,6 +88,26 @@
   }
 
 
+  void  PluginsErrorDictionary::LogError(const OrthancException& exception)
+  {
+    if (exception.GetErrorCode() >= ErrorCode_START_PLUGINS)
+    {
+      boost::mutex::scoped_lock lock(mutex_);
+      Errors::const_iterator error = errors_.find(static_cast<int32_t>(exception.GetErrorCode()));
+      
+      if (error != errors_.end())
+      {
+        LOG(ERROR) << "Error code " << error->second->pluginCode_
+                   << " inside plugin \"" << error->second->pluginName_
+                   << "\": " << error->second->message_;
+        return;
+      }
+    }
+
+    LOG(ERROR) << "Exception inside the plugin engine: " << exception.What();
+  }
+
+
   bool  PluginsErrorDictionary::Format(Json::Value& message,    /* out */
                                        HttpStatus& httpStatus,  /* out */
                                        const OrthancException& exception)