Mercurial > hg > orthanc
changeset 6415:b0402a2b2ddf
removed overloaded constructors of OrthancException with payload
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sat, 15 Nov 2025 10:19:06 +0100 |
| parents | dce1bef431b7 |
| children | 68001db8ed4a |
| files | OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp OrthancFramework/Sources/OrthancException.cpp OrthancFramework/Sources/OrthancException.h |
| diffstat | 5 files changed, 27 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Sat Nov 15 10:09:58 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Sat Nov 15 10:19:06 2025 +0100 @@ -394,17 +394,15 @@ "C-FIND SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus) + - " (unable to process - invalid query ?)", - ErrorPayloadType_Dimse, - MakeDimseErrorStatusPayload(response.DimseStatus)); + " (unable to process - invalid query ?)") + .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } else { throw OrthancException(ErrorCode_NetworkProtocol, "C-FIND SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + - "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus), - ErrorPayloadType_Dimse, - MakeDimseErrorStatusPayload(response.DimseStatus)); + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus)) + .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } } } @@ -526,17 +524,15 @@ "C-MOVE SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus) + - " (unable to process - resource not found ?)", - ErrorPayloadType_Dimse, - MakeDimseErrorStatusPayload(response.DimseStatus)); + " (unable to process - resource not found ?)") + .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } else { throw OrthancException(ErrorCode_NetworkProtocol, "C-MOVE SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + - "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus), - ErrorPayloadType_Dimse, - MakeDimseErrorStatusPayload(response.DimseStatus)); + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus)) + .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } } } @@ -671,9 +667,8 @@ throw OrthancException(ErrorCode_NetworkProtocol, "C-GET SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + - "\" has failed with DIMSE status " + DimseToHexString(rsp.msg.CGetRSP.DimseStatus), - ErrorPayloadType_Dimse, - MakeDimseErrorStatusPayload(rsp.msg.CGetRSP.DimseStatus)); + "\" has failed with DIMSE status " + DimseToHexString(rsp.msg.CGetRSP.DimseStatus)) + .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(rsp.msg.CGetRSP.DimseStatus)); } } // Handle C-STORE Request
--- a/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp Sat Nov 15 10:09:58 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp Sat Nov 15 10:19:06 2025 +0100 @@ -464,9 +464,8 @@ throw OrthancException(ErrorCode_NetworkProtocol, "C-STORE SCU to AET \"" + GetParameters().GetRemoteModality().GetApplicationEntityTitle() + - "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus), - ErrorPayloadType_Dimse, - MakeDimseErrorStatusPayload(response.DimseStatus)); + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus)) + .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } }
--- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Sat Nov 15 10:09:58 2025 +0100 +++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Sat Nov 15 10:19:06 2025 +0100 @@ -904,12 +904,11 @@ if (jobErrorPayload.HasContent()) { - throw OrthancException(code, details, jobErrorPayload.GetType(), jobErrorPayload.GetContent()); + throw OrthancException(code, details).SetPayload(jobErrorPayload); } else if (it->second->GetLastStatus().GetErrorPayload().HasContent()) { - throw OrthancException(code, details, it->second->GetLastStatus().GetErrorPayload().GetType(), - it->second->GetLastStatus().GetErrorPayload().GetContent()); + throw OrthancException(code, details).SetPayload(it->second->GetLastStatus().GetErrorPayload()); } else if (!details.empty()) {
--- a/OrthancFramework/Sources/OrthancException.cpp Sat Nov 15 10:09:58 2025 +0100 +++ b/OrthancFramework/Sources/OrthancException.cpp Sat Nov 15 10:19:06 2025 +0100 @@ -157,48 +157,6 @@ OrthancException::OrthancException(ErrorCode errorCode, - const std::string& details, - ErrorPayloadType payloadType, - const Json::Value& payload, - LogException log) : - errorCode_(errorCode), - httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)), - logged_(log == LogException_Yes), - details_(new std::string(details)) - { - payload_.SetContent(payloadType, payload); - -#if ORTHANC_ENABLE_LOGGING == 1 - if (log == LogException_Yes) - { - LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; - } -#endif - } - - - OrthancException::OrthancException(ErrorCode errorCode, - HttpStatus httpStatus, - const std::string& details, - ErrorPayloadType payloadType, - const Json::Value& payload, - LogException log) : - errorCode_(errorCode), - httpStatus_(httpStatus), - logged_(log == LogException_Yes), - details_(new std::string(details)) - { - payload_.SetContent(payloadType, payload); - -#if ORTHANC_ENABLE_LOGGING == 1 - if (log == LogException_Yes) - { - LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; - } -#endif - } - - OrthancException::OrthancException(ErrorCode errorCode, HttpStatus httpStatus, const std::string& details, LogException log) :
--- a/OrthancFramework/Sources/OrthancException.h Sat Nov 15 10:09:58 2025 +0100 +++ b/OrthancFramework/Sources/OrthancException.h Sat Nov 15 10:19:06 2025 +0100 @@ -107,12 +107,6 @@ LogException log = LogException_Yes); OrthancException(ErrorCode errorCode, - const std::string& details, - ErrorPayloadType type, - const Json::Value& payload, - LogException log = LogException_Yes); - - OrthancException(ErrorCode errorCode, HttpStatus httpStatus); OrthancException(ErrorCode errorCode, @@ -120,14 +114,6 @@ const std::string& details, LogException log = LogException_Yes); - - OrthancException(ErrorCode errorCode, - HttpStatus httpStatus, - const std::string& details, - ErrorPayloadType type, - const Json::Value& payload, - LogException log = LogException_Yes); - ErrorCode GetErrorCode() const; HttpStatus GetHttpStatus() const; @@ -143,6 +129,19 @@ return logged_; } + OrthancException& SetPayload(const ErrorPayload& payload) + { + payload_ = payload; + return *this; + } + + OrthancException& SetPayload(ErrorPayloadType type, + const Json::Value& content) + { + payload_.SetContent(type, content); + return *this; + } + ErrorPayload& GetPayload() { return payload_;
