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