diff Core/OrthancException.h @ 1576:de54c19fc44d

refactoring OrthancException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 14:48:06 +0200
parents f8aae45011c9
children 7aac0cddd42e
line wrap: on
line diff
--- a/Core/OrthancException.h	Tue Aug 25 14:00:57 2015 +0200
+++ b/Core/OrthancException.h	Tue Aug 25 14:48:06 2015 +0200
@@ -61,7 +61,11 @@
     {
     }
 
-    OrthancException(ErrorCode errorCode);
+    OrthancException(ErrorCode errorCode) : 
+      errorCode_(errorCode),
+      httpStatus_(ConvertErrorCodeToHttpStatus(errorCode))
+    {
+    }
 
     OrthancException(ErrorCode errorCode,
                      HttpStatus httpStatus) :
@@ -80,6 +84,16 @@
       return httpStatus_;
     }
 
-    const char* What() const;
+    const char* What() const
+    {
+      if (errorCode_ == ErrorCode_Custom)
+      {
+        return custom_.c_str();
+      }
+      else
+      {
+        return EnumerationToString(errorCode_);
+      }
+    }
   };
 }