Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/Core/OrthancException.h Tue Aug 25 13:37:57 2015 +0200 +++ b/Core/OrthancException.h Tue Aug 25 14:00:57 2015 +0200 @@ -40,31 +40,44 @@ class OrthancException { protected: - ErrorCode error_; + ErrorCode errorCode_; + HttpStatus httpStatus_; std::string custom_; + static HttpStatus ConvertToHttpStatus(ErrorCode code); + public: - static const char* GetDescription(ErrorCode error); - OrthancException(const char* custom) : - error_(ErrorCode_Custom), + errorCode_(ErrorCode_Custom), + httpStatus_(HttpStatus_500_InternalServerError), custom_(custom) { } OrthancException(const std::string& custom) : - error_(ErrorCode_Custom), + errorCode_(ErrorCode_Custom), + httpStatus_(HttpStatus_500_InternalServerError), custom_(custom) { } - OrthancException(ErrorCode error) : error_(error) + OrthancException(ErrorCode errorCode); + + OrthancException(ErrorCode errorCode, + HttpStatus httpStatus) : + errorCode_(errorCode), + httpStatus_(httpStatus) { } ErrorCode GetErrorCode() const { - return error_; + return errorCode_; + } + + HttpStatus GetHttpStatus() const + { + return httpStatus_; } const char* What() const;