comparison 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
comparison
equal deleted inserted replaced
1642:0669d05b6de1 1643:87c77b9b3679
30 **/ 30 **/
31 31
32 32
33 #pragma once 33 #pragma once
34 34
35 #include <stdint.h>
35 #include <string> 36 #include <string>
36 #include "Enumerations.h" 37 #include "Enumerations.h"
37 38
38 namespace Orthanc 39 namespace Orthanc
39 { 40 {
40 class OrthancException 41 class OrthancException
41 { 42 {
42 protected: 43 protected:
43 ErrorCode errorCode_; 44 ErrorCode errorCode_;
44 HttpStatus httpStatus_; 45 HttpStatus httpStatus_;
46 int32_t pluginCode_;
47
48 OrthancException(ErrorCode errorCode,
49 HttpStatus httpStatus,
50 int32_t pluginCode) :
51 errorCode_(errorCode),
52 httpStatus_(httpStatus),
53 pluginCode_(0)
54 {
55 }
45 56
46 public: 57 public:
47 OrthancException(ErrorCode errorCode) : 58 OrthancException(ErrorCode errorCode) :
48 errorCode_(errorCode), 59 errorCode_(errorCode),
49 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)) 60 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)),
61 pluginCode_(0)
50 { 62 {
51 } 63 }
52 64
53 OrthancException(ErrorCode errorCode, 65 OrthancException(ErrorCode errorCode,
54 HttpStatus httpStatus) : 66 HttpStatus httpStatus) :
55 errorCode_(errorCode), 67 errorCode_(errorCode),
56 httpStatus_(httpStatus) 68 httpStatus_(httpStatus),
69 pluginCode_(0)
57 { 70 {
71 }
72
73 static OrthancException GetPluginException(int32_t pluginCode,
74 HttpStatus httpStatus)
75 {
76 return OrthancException(ErrorCode_Plugin, httpStatus, pluginCode);
58 } 77 }
59 78
60 ErrorCode GetErrorCode() const 79 ErrorCode GetErrorCode() const
61 { 80 {
62 return errorCode_; 81 return errorCode_;
65 HttpStatus GetHttpStatus() const 84 HttpStatus GetHttpStatus() const
66 { 85 {
67 return httpStatus_; 86 return httpStatus_;
68 } 87 }
69 88
89 int32_t GetPluginErrorCode() const
90 {
91 return pluginCode_;
92 }
93
70 const char* What() const 94 const char* What() const
71 { 95 {
72 return EnumerationToString(errorCode_); 96 return EnumerationToString(errorCode_);
73 } 97 }
74 }; 98 };