Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/Common/OrthancPluginException.h @ 4123:3d6ee570cfb2 framework-lgpl
adding missing licenses to sample plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 20:08:57 +0200 |
parents | 4bb7522a63e0 |
children | d9473bd5ed43 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * License, or (at your option) any later version. |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * 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
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * General Public License for more details. |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * 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
|
18 * 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
|
19 **/ |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
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 #pragma once |
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 #if !defined(HAS_ORTHANC_EXCEPTION) |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 # error The macro HAS_ORTHANC_EXCEPTION must be defined |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #endif |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #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
|
30 # include <OrthancException.h> |
2239 | 31 # define ORTHANC_PLUGINS_ERROR_ENUMERATION ::Orthanc::ErrorCode |
32 # define ORTHANC_PLUGINS_EXCEPTION_CLASS ::Orthanc::OrthancException | |
33 # 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
|
34 #else |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 # include <orthanc/OrthancCPlugin.h> |
2239 | 36 # define ORTHANC_PLUGINS_ERROR_ENUMERATION ::OrthancPluginErrorCode |
37 # define ORTHANC_PLUGINS_EXCEPTION_CLASS ::OrthancPlugins::PluginException | |
38 # define ORTHANC_PLUGINS_GET_ERROR_CODE(code) ::OrthancPluginErrorCode_ ## code | |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 #endif |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 #define ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code) \ |
2239 | 43 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
|
44 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 #define ORTHANC_PLUGINS_THROW_EXCEPTION(code) \ |
2239 | 47 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
|
48 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 #define ORTHANC_PLUGINS_CHECK_ERROR(code) \ |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 if (code != ORTHANC_PLUGINS_GET_ERROR_CODE(Success)) \ |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { \ |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 ORTHANC_PLUGINS_THROW_EXCEPTION(code); \ |
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 |
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 namespace OrthancPlugins |
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 #if HAS_ORTHANC_EXCEPTION == 0 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 class PluginException |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 private: |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 OrthancPluginErrorCode code_; |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 public: |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 explicit PluginException(OrthancPluginErrorCode code) : code_(code) |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 } |
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 OrthancPluginErrorCode GetErrorCode() const |
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 return code_; |
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 |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 const char* What(OrthancPluginContext* context) const |
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* description = OrthancPluginGetErrorDescription(context, code_); |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 if (description) |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 return 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 else |
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 return "No description available"; |
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 } |
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 #endif |
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 } |