# HG changeset patch # User Sebastien Jodogne # Date 1763198346 -3600 # Node ID b0402a2b2ddf9e865d9386431ae72306315b47a6 # Parent dce1bef431b77de6b3cd946a8abe9c6bc7be0cfd removed overloaded constructors of OrthancException with payload diff -r dce1bef431b7 -r b0402a2b2ddf OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp --- 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 diff -r dce1bef431b7 -r b0402a2b2ddf OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp --- 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)); } } diff -r dce1bef431b7 -r b0402a2b2ddf OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp --- 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()) { diff -r dce1bef431b7 -r b0402a2b2ddf OrthancFramework/Sources/OrthancException.cpp --- 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) : diff -r dce1bef431b7 -r b0402a2b2ddf OrthancFramework/Sources/OrthancException.h --- 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_;