diff Core/OrthancException.h @ 1643:87c77b9b3679

provision for error codes in plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Sep 2015 14:42:20 +0200
parents 9ea3d082b064
children 939b921b2c81
line wrap: on
line diff
--- a/Core/OrthancException.h	Wed Sep 23 13:39:00 2015 +0200
+++ b/Core/OrthancException.h	Wed Sep 23 14:42:20 2015 +0200
@@ -32,6 +32,7 @@
 
 #pragma once
 
+#include <stdint.h>
 #include <string>
 #include "Enumerations.h"
 
@@ -40,23 +41,41 @@
   class OrthancException
   {
   protected:
-    ErrorCode errorCode_;
+    ErrorCode  errorCode_;
     HttpStatus httpStatus_;
+    int32_t    pluginCode_;
+
+    OrthancException(ErrorCode errorCode,
+                     HttpStatus httpStatus,
+                     int32_t pluginCode) :
+      errorCode_(errorCode),
+      httpStatus_(httpStatus),
+      pluginCode_(0)
+    {
+    }
 
   public:
     OrthancException(ErrorCode errorCode) : 
       errorCode_(errorCode),
-      httpStatus_(ConvertErrorCodeToHttpStatus(errorCode))
+      httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)),
+      pluginCode_(0)
     {
     }
 
     OrthancException(ErrorCode errorCode,
                      HttpStatus httpStatus) :
       errorCode_(errorCode),
-      httpStatus_(httpStatus)
+      httpStatus_(httpStatus),
+      pluginCode_(0)
     {
     }
 
+    static OrthancException GetPluginException(int32_t  pluginCode,
+                                               HttpStatus  httpStatus)
+    {
+      return OrthancException(ErrorCode_Plugin, httpStatus, pluginCode);
+    }
+
     ErrorCode GetErrorCode() const
     {
       return errorCode_;
@@ -67,6 +86,11 @@
       return httpStatus_;
     }
 
+    int32_t GetPluginErrorCode() const
+    {
+      return pluginCode_;
+    }
+
     const char* What() const
     {
       return EnumerationToString(errorCode_);