Mercurial > hg > orthanc-stone
annotate RenderingPlugin/Resources/Orthanc/Plugins/OrthancPluginException.h @ 1950:6ffd65cfd2ee deep-learning
new branch: deep-learning
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Aug 2022 15:48:35 +0200 |
parents | a2955abe4c2e |
children | 07964689cb0b |
rev | line source |
---|---|
1538
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1868
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1868
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1538
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
1638 | 12 * |
1538
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #pragma once |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #if !defined(HAS_ORTHANC_EXCEPTION) |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 # error The macro HAS_ORTHANC_EXCEPTION must be defined |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #endif |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #if HAS_ORTHANC_EXCEPTION == 1 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 # include <OrthancException.h> |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 # define ORTHANC_PLUGINS_ERROR_ENUMERATION ::Orthanc::ErrorCode |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 # define ORTHANC_PLUGINS_EXCEPTION_CLASS ::Orthanc::OrthancException |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 # define ORTHANC_PLUGINS_GET_ERROR_CODE(code) ::Orthanc::ErrorCode_ ## code |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #else |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 # include <orthanc/OrthancCPlugin.h> |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 # define ORTHANC_PLUGINS_ERROR_ENUMERATION ::OrthancPluginErrorCode |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 # define ORTHANC_PLUGINS_EXCEPTION_CLASS ::OrthancPlugins::PluginException |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 # define ORTHANC_PLUGINS_GET_ERROR_CODE(code) ::OrthancPluginErrorCode_ ## code |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 #endif |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 #define ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code) \ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 throw ORTHANC_PLUGINS_EXCEPTION_CLASS(static_cast<ORTHANC_PLUGINS_ERROR_ENUMERATION>(code)); |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 #define ORTHANC_PLUGINS_THROW_EXCEPTION(code) \ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 throw ORTHANC_PLUGINS_EXCEPTION_CLASS(ORTHANC_PLUGINS_GET_ERROR_CODE(code)); |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 #define ORTHANC_PLUGINS_CHECK_ERROR(code) \ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 if (code != ORTHANC_PLUGINS_GET_ERROR_CODE(Success)) \ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { \ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 ORTHANC_PLUGINS_THROW_EXCEPTION(code); \ |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 } |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 namespace OrthancPlugins |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 #if HAS_ORTHANC_EXCEPTION == 0 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 class PluginException |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 private: |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 OrthancPluginErrorCode code_; |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 public: |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 explicit PluginException(OrthancPluginErrorCode code) : code_(code) |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 OrthancPluginErrorCode GetErrorCode() const |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 return code_; |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 } |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 const char* What(OrthancPluginContext* context) const |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 const char* description = OrthancPluginGetErrorDescription(context, code_); |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 if (description) |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 return description; |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 else |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 { |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 return "No description available"; |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 }; |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 #endif |
d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 } |