annotate OrthancFramework/Sources/OrthancException.cpp @ 4706:dbee8bd8ee1f

display OpenSSL version in the logs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Jun 2021 09:13:03 +0200
parents d9473bd5ed43
children 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * License along with this program. If not, see
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "PrecompiledHeaders.h"
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "OrthancException.h"
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "Logging.h"
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace Orthanc
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 OrthancException::OrthancException(const OrthancException& other) :
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 errorCode_(other.errorCode_),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 httpStatus_(other.httpStatus_)
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 if (other.details_.get() != NULL)
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 details_.reset(new std::string(*other.details_));
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 OrthancException::OrthancException(ErrorCode errorCode) :
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 errorCode_(errorCode),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode))
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 OrthancException::OrthancException(ErrorCode errorCode,
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 const std::string& details,
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 bool log) :
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 errorCode_(errorCode),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 details_(new std::string(details))
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 #if ORTHANC_ENABLE_LOGGING == 1
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 if (log)
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details;
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 #endif
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 OrthancException::OrthancException(ErrorCode errorCode,
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 HttpStatus httpStatus) :
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 errorCode_(errorCode),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 httpStatus_(httpStatus)
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 OrthancException::OrthancException(ErrorCode errorCode,
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 HttpStatus httpStatus,
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const std::string& details,
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 bool log) :
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 errorCode_(errorCode),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 httpStatus_(httpStatus),
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 details_(new std::string(details))
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 #if ORTHANC_ENABLE_LOGGING == 1
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 if (log)
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details;
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 #endif
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ErrorCode OrthancException::GetErrorCode() const
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 return errorCode_;
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 HttpStatus OrthancException::GetHttpStatus() const
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 return httpStatus_;
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 const char* OrthancException::What() const
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return EnumerationToString(errorCode_);
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 bool OrthancException::HasDetails() const
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 return details_.get() != NULL;
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 const char* OrthancException::GetDetails() const
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if (details_.get() == NULL)
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 return "";
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 else
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 return details_->c_str();
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }