Mercurial > hg > orthanc
comparison Core/OrthancException.h @ 1575:f8aae45011c9
exceptions now carry HTTP status
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Aug 2015 14:00:57 +0200 |
parents | 6e7e5ed91c2d |
children | de54c19fc44d |
comparison
equal
deleted
inserted
replaced
1574:0c29ebe80ac9 | 1575:f8aae45011c9 |
---|---|
38 namespace Orthanc | 38 namespace Orthanc |
39 { | 39 { |
40 class OrthancException | 40 class OrthancException |
41 { | 41 { |
42 protected: | 42 protected: |
43 ErrorCode error_; | 43 ErrorCode errorCode_; |
44 HttpStatus httpStatus_; | |
44 std::string custom_; | 45 std::string custom_; |
45 | 46 |
47 static HttpStatus ConvertToHttpStatus(ErrorCode code); | |
48 | |
46 public: | 49 public: |
47 static const char* GetDescription(ErrorCode error); | |
48 | |
49 OrthancException(const char* custom) : | 50 OrthancException(const char* custom) : |
50 error_(ErrorCode_Custom), | 51 errorCode_(ErrorCode_Custom), |
52 httpStatus_(HttpStatus_500_InternalServerError), | |
51 custom_(custom) | 53 custom_(custom) |
52 { | 54 { |
53 } | 55 } |
54 | 56 |
55 OrthancException(const std::string& custom) : | 57 OrthancException(const std::string& custom) : |
56 error_(ErrorCode_Custom), | 58 errorCode_(ErrorCode_Custom), |
59 httpStatus_(HttpStatus_500_InternalServerError), | |
57 custom_(custom) | 60 custom_(custom) |
58 { | 61 { |
59 } | 62 } |
60 | 63 |
61 OrthancException(ErrorCode error) : error_(error) | 64 OrthancException(ErrorCode errorCode); |
65 | |
66 OrthancException(ErrorCode errorCode, | |
67 HttpStatus httpStatus) : | |
68 errorCode_(errorCode), | |
69 httpStatus_(httpStatus) | |
62 { | 70 { |
63 } | 71 } |
64 | 72 |
65 ErrorCode GetErrorCode() const | 73 ErrorCode GetErrorCode() const |
66 { | 74 { |
67 return error_; | 75 return errorCode_; |
76 } | |
77 | |
78 HttpStatus GetHttpStatus() const | |
79 { | |
80 return httpStatus_; | |
68 } | 81 } |
69 | 82 |
70 const char* What() const; | 83 const char* What() const; |
71 }; | 84 }; |
72 } | 85 } |