comparison OrthancFramework/Sources/OrthancException.cpp @ 5100:9d51c000e91a

more verbose HTTPClient errors + avoid duplicate logging of same error
author Alain Mazy <am@osimis.io>
date Wed, 19 Oct 2022 12:40:14 +0200
parents 43e613a7756b
children 0ea402b4d901
comparison
equal deleted inserted replaced
5099:edefb278cb77 5100:9d51c000e91a
29 29
30 namespace Orthanc 30 namespace Orthanc
31 { 31 {
32 OrthancException::OrthancException(const OrthancException& other) : 32 OrthancException::OrthancException(const OrthancException& other) :
33 errorCode_(other.errorCode_), 33 errorCode_(other.errorCode_),
34 httpStatus_(other.httpStatus_) 34 httpStatus_(other.httpStatus_),
35 logged_(false)
35 { 36 {
36 if (other.details_.get() != NULL) 37 if (other.details_.get() != NULL)
37 { 38 {
38 details_.reset(new std::string(*other.details_)); 39 details_.reset(new std::string(*other.details_));
39 } 40 }
40 } 41 }
41 42
42 OrthancException::OrthancException(ErrorCode errorCode) : 43 OrthancException::OrthancException(ErrorCode errorCode) :
43 errorCode_(errorCode), 44 errorCode_(errorCode),
44 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)) 45 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)),
46 logged_(false)
45 { 47 {
46 } 48 }
47 49
48 OrthancException::OrthancException(ErrorCode errorCode, 50 OrthancException::OrthancException(ErrorCode errorCode,
49 const std::string& details, 51 const std::string& details,
50 bool log) : 52 bool log) :
51 errorCode_(errorCode), 53 errorCode_(errorCode),
52 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)), 54 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)),
55 logged_(log),
53 details_(new std::string(details)) 56 details_(new std::string(details))
54 { 57 {
55 #if ORTHANC_ENABLE_LOGGING == 1 58 #if ORTHANC_ENABLE_LOGGING == 1
56 if (log) 59 if (log)
57 { 60 {
61 } 64 }
62 65
63 OrthancException::OrthancException(ErrorCode errorCode, 66 OrthancException::OrthancException(ErrorCode errorCode,
64 HttpStatus httpStatus) : 67 HttpStatus httpStatus) :
65 errorCode_(errorCode), 68 errorCode_(errorCode),
66 httpStatus_(httpStatus) 69 httpStatus_(httpStatus),
70 logged_(false)
67 { 71 {
68 } 72 }
69 73
70 OrthancException::OrthancException(ErrorCode errorCode, 74 OrthancException::OrthancException(ErrorCode errorCode,
71 HttpStatus httpStatus, 75 HttpStatus httpStatus,
72 const std::string& details, 76 const std::string& details,
73 bool log) : 77 bool log) :
74 errorCode_(errorCode), 78 errorCode_(errorCode),
75 httpStatus_(httpStatus), 79 httpStatus_(httpStatus),
80 logged_(log),
76 details_(new std::string(details)) 81 details_(new std::string(details))
77 { 82 {
78 #if ORTHANC_ENABLE_LOGGING == 1 83 #if ORTHANC_ENABLE_LOGGING == 1
79 if (log) 84 if (log)
80 { 85 {
112 else 117 else
113 { 118 {
114 return details_->c_str(); 119 return details_->c_str();
115 } 120 }
116 } 121 }
122
123 bool OrthancException::HasBeenLogged() const
124 {
125 return logged_;
126 }
127
117 } 128 }