Mercurial > hg > orthanc-stone
annotate Framework/StoneException.h @ 307:be2660b6e40a am-callable-and-promise
wip: commands + status update
author | am@osimis.io |
---|---|
date | Tue, 25 Sep 2018 15:14:53 +0200 |
parents | 1992f7b8563e |
children | 3a4ca166fafa |
rev | line source |
---|---|
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
1 /** |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
6 * |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
11 * |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
16 * |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
19 **/ |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
20 |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
21 |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
22 #pragma once |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
23 |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
24 #include "Core/OrthancException.h" |
297 | 25 #include <boost/lexical_cast.hpp> |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
26 |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
27 namespace OrthancStone |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
28 { |
297 | 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 | |
307 | 35 |
297 | 36 ErrorCode_PromiseSingleSuccessHandler, // a Promise can only have a single success handler |
37 ErrorCode_PromiseSingleFailureHandler, // a Promise can only have a single failure handler | |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
38 |
307 | 39 ErrorCode_CommandJsonInvalidFormat, |
297 | 40 ErrorCode_Last |
41 }; | |
42 | |
43 | |
44 | |
45 class StoneException | |
46 { | |
47 protected: | |
48 OrthancStone::ErrorCode errorCode_; | |
49 | |
50 public: | |
51 explicit StoneException(ErrorCode errorCode) : | |
52 errorCode_(errorCode) | |
53 { | |
54 } | |
55 | |
56 ErrorCode GetErrorCode() const | |
57 { | |
58 return errorCode_; | |
59 } | |
60 | |
61 virtual const char* What() const | |
62 { | |
63 return "TODO: EnumerationToString for StoneException"; | |
64 } | |
65 }; | |
66 | |
67 class StoneOrthancException : public StoneException | |
68 { | |
69 protected: | |
70 Orthanc::OrthancException& orthancException_; | |
71 | |
72 public: | |
73 explicit StoneOrthancException(Orthanc::OrthancException& orthancException) : | |
74 StoneException(ErrorCode_OrthancError), | |
75 orthancException_(orthancException) | |
76 { | |
77 } | |
78 | |
79 Orthanc::ErrorCode GetOrthancErrorCode() const | |
80 { | |
81 return orthancException_.GetErrorCode(); | |
82 } | |
83 | |
84 virtual const char* What() const | |
85 { | |
86 return orthancException_.What(); | |
87 } | |
88 }; | |
89 | |
90 class StoneApplicationException : public StoneException | |
91 { | |
92 protected: | |
93 int applicationErrorCode_; | |
94 | |
95 public: | |
96 explicit StoneApplicationException(int applicationErrorCode) : | |
97 StoneException(ErrorCode_ApplicationException), | |
98 applicationErrorCode_(applicationErrorCode) | |
99 { | |
100 } | |
101 | |
102 int GetApplicationErrorCode() const | |
103 { | |
104 return applicationErrorCode_; | |
105 } | |
106 | |
107 virtual const char* What() const | |
108 { | |
109 return boost::lexical_cast<std::string>(applicationErrorCode_).c_str(); | |
110 } | |
111 }; | |
295
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
112 |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
113 } |
b04b13810540
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
am@osimis.io
parents:
diff
changeset
|
114 |