Mercurial > hg > orthanc-stone
comparison Framework/StoneException.h @ 297:1992f7b8563e am-2
introduced StoneException
author | am@osimis.io |
---|---|
date | Mon, 10 Sep 2018 12:22:05 +0200 |
parents | b04b13810540 |
children | be2660b6e40a |
comparison
equal
deleted
inserted
replaced
296:ac9fd144feae | 297:1992f7b8563e |
---|---|
20 | 20 |
21 | 21 |
22 #pragma once | 22 #pragma once |
23 | 23 |
24 #include "Core/OrthancException.h" | 24 #include "Core/OrthancException.h" |
25 #include <boost/lexical_cast.hpp> | |
25 | 26 |
26 namespace OrthancStone | 27 namespace OrthancStone |
27 { | 28 { |
29 enum ErrorCode | |
30 { | |
31 ErrorCode_Success, | |
32 ErrorCode_OrthancError, // this StoneException is actually an OrthancException with an Orthanc error code | |
33 ErrorCode_ApplicationException, // this StoneException is specific to an application (and should have its own internal error code) | |
34 ErrorCode_NotImplemented, // case not implemented | |
35 ErrorCode_PromiseSingleSuccessHandler, // a Promise can only have a single success handler | |
36 ErrorCode_PromiseSingleFailureHandler, // a Promise can only have a single failure handler | |
28 | 37 |
38 ErrorCode_Last | |
39 }; | |
40 | |
41 | |
42 | |
43 class StoneException | |
44 { | |
45 protected: | |
46 OrthancStone::ErrorCode errorCode_; | |
47 | |
48 public: | |
49 explicit StoneException(ErrorCode errorCode) : | |
50 errorCode_(errorCode) | |
51 { | |
52 } | |
53 | |
54 ErrorCode GetErrorCode() const | |
55 { | |
56 return errorCode_; | |
57 } | |
58 | |
59 virtual const char* What() const | |
60 { | |
61 return "TODO: EnumerationToString for StoneException"; | |
62 } | |
63 }; | |
64 | |
65 class StoneOrthancException : public StoneException | |
66 { | |
67 protected: | |
68 Orthanc::OrthancException& orthancException_; | |
69 | |
70 public: | |
71 explicit StoneOrthancException(Orthanc::OrthancException& orthancException) : | |
72 StoneException(ErrorCode_OrthancError), | |
73 orthancException_(orthancException) | |
74 { | |
75 } | |
76 | |
77 Orthanc::ErrorCode GetOrthancErrorCode() const | |
78 { | |
79 return orthancException_.GetErrorCode(); | |
80 } | |
81 | |
82 virtual const char* What() const | |
83 { | |
84 return orthancException_.What(); | |
85 } | |
86 }; | |
87 | |
88 class StoneApplicationException : public StoneException | |
89 { | |
90 protected: | |
91 int applicationErrorCode_; | |
92 | |
93 public: | |
94 explicit StoneApplicationException(int applicationErrorCode) : | |
95 StoneException(ErrorCode_ApplicationException), | |
96 applicationErrorCode_(applicationErrorCode) | |
97 { | |
98 } | |
99 | |
100 int GetApplicationErrorCode() const | |
101 { | |
102 return applicationErrorCode_; | |
103 } | |
104 | |
105 virtual const char* What() const | |
106 { | |
107 return boost::lexical_cast<std::string>(applicationErrorCode_).c_str(); | |
108 } | |
109 }; | |
29 | 110 |
30 } | 111 } |
31 | 112 |