comparison Core/OrthancException.h @ 2960:74a5a7fd6e0e

log flag to OrthancPluginSetHttpErrorDetails
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Dec 2018 18:56:39 +0100
parents d924f9bb61cc
children 9cc3d40e389b
comparison
equal deleted inserted replaced
2959:7364415851ac 2960:74a5a7fd6e0e
71 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)) 71 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode))
72 { 72 {
73 } 73 }
74 74
75 OrthancException(ErrorCode errorCode, 75 OrthancException(ErrorCode errorCode,
76 const std::string& details) : 76 const std::string& details,
77 bool log = true) :
77 errorCode_(errorCode), 78 errorCode_(errorCode),
78 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)), 79 httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)),
79 details_(new std::string(details)) 80 details_(new std::string(details))
80 { 81 {
81 #if ORTHANC_ENABLE_LOGGING == 1 82 #if ORTHANC_ENABLE_LOGGING == 1
82 LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; 83 if (log)
84 {
85 LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details;
86 }
83 #endif 87 #endif
84 } 88 }
85 89
86 OrthancException(ErrorCode errorCode, 90 OrthancException(ErrorCode errorCode,
87 HttpStatus httpStatus) : 91 HttpStatus httpStatus) :
90 { 94 {
91 } 95 }
92 96
93 OrthancException(ErrorCode errorCode, 97 OrthancException(ErrorCode errorCode,
94 HttpStatus httpStatus, 98 HttpStatus httpStatus,
95 const std::string& details) : 99 const std::string& details,
100 bool log = true) :
96 errorCode_(errorCode), 101 errorCode_(errorCode),
97 httpStatus_(httpStatus), 102 httpStatus_(httpStatus),
98 details_(new std::string(details)) 103 details_(new std::string(details))
99 { 104 {
100 #if ORTHANC_ENABLE_LOGGING == 1 105 #if ORTHANC_ENABLE_LOGGING == 1
101 LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; 106 if (log)
107 {
108 LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details;
109 }
102 #endif 110 #endif
103 } 111 }
104 112
105 ErrorCode GetErrorCode() const 113 ErrorCode GetErrorCode() const
106 { 114 {