# HG changeset patch # User Sebastien Jodogne # Date 1763198695 -3600 # Node ID 68001db8ed4a54d2015e8ceabd7eec3d152681be # Parent b0402a2b2ddf9e865d9386431ae72306315b47a6 removed overloaded constructors of OrthancException with HTTP status diff -r b0402a2b2ddf -r 68001db8ed4a OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp --- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Sat Nov 15 10:19:06 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Sat Nov 15 10:24:55 2025 +0100 @@ -390,11 +390,11 @@ if (response.DimseStatus == STATUS_FIND_Failed_UnableToProcess) { throw OrthancException(ErrorCode_NetworkProtocol, - HttpStatus_422_UnprocessableEntity, "C-FIND SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus) + " (unable to process - invalid query ?)") + .SetHttpStatus(HttpStatus_422_UnprocessableEntity) .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } else @@ -520,11 +520,11 @@ if (response.DimseStatus == STATUS_MOVE_Failed_UnableToProcess) { throw OrthancException(ErrorCode_NetworkProtocol, - HttpStatus_422_UnprocessableEntity, "C-MOVE SCU to AET \"" + parameters_.GetRemoteModality().GetApplicationEntityTitle() + "\" has failed with DIMSE status " + DimseToHexString(response.DimseStatus) + " (unable to process - resource not found ?)") + .SetHttpStatus(HttpStatus_422_UnprocessableEntity) .SetPayload(ErrorPayloadType_Dimse, MakeDimseErrorStatusPayload(response.DimseStatus)); } else diff -r b0402a2b2ddf -r 68001db8ed4a OrthancFramework/Sources/OrthancException.cpp --- a/OrthancFramework/Sources/OrthancException.cpp Sat Nov 15 10:19:06 2025 +0100 +++ b/OrthancFramework/Sources/OrthancException.cpp Sat Nov 15 10:24:55 2025 +0100 @@ -147,32 +147,6 @@ } - OrthancException::OrthancException(ErrorCode errorCode, - HttpStatus httpStatus) : - errorCode_(errorCode), - httpStatus_(httpStatus), - logged_(false) - { - } - - - OrthancException::OrthancException(ErrorCode errorCode, - HttpStatus httpStatus, - const std::string& details, - LogException log) : - errorCode_(errorCode), - httpStatus_(httpStatus), - logged_(log == LogException_Yes), - details_(new std::string(details)) - { -#if ORTHANC_ENABLE_LOGGING == 1 - if (log == LogException_Yes) - { - LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; - } -#endif - } - ErrorCode OrthancException::GetErrorCode() const { return errorCode_; diff -r b0402a2b2ddf -r 68001db8ed4a OrthancFramework/Sources/OrthancException.h --- a/OrthancFramework/Sources/OrthancException.h Sat Nov 15 10:19:06 2025 +0100 +++ b/OrthancFramework/Sources/OrthancException.h Sat Nov 15 10:24:55 2025 +0100 @@ -106,14 +106,6 @@ const std::string& details, LogException log = LogException_Yes); - OrthancException(ErrorCode errorCode, - HttpStatus httpStatus); - - OrthancException(ErrorCode errorCode, - HttpStatus httpStatus, - const std::string& details, - LogException log = LogException_Yes); - ErrorCode GetErrorCode() const; HttpStatus GetHttpStatus() const; @@ -129,6 +121,12 @@ return logged_; } + OrthancException& SetHttpStatus(HttpStatus status) + { + httpStatus_ = status; + return *this; + } + OrthancException& SetPayload(const ErrorPayload& payload) { payload_ = payload; diff -r b0402a2b2ddf -r 68001db8ed4a OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Sat Nov 15 10:19:06 2025 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Sat Nov 15 10:24:55 2025 +0100 @@ -2718,12 +2718,14 @@ if (transaction.HasReachedMaxStorageSize(maximumStorageSize_, instanceSize)) { storeStatus_ = StoreStatus_StorageFull; - throw OrthancException(ErrorCode_FullStorage, HttpStatus_507_InsufficientStorage, "Maximum storage size reached"); // throw to cancel the transaction + throw OrthancException(ErrorCode_FullStorage, "Maximum storage size reached") // throw to cancel the transaction + .SetHttpStatus(HttpStatus_507_InsufficientStorage); } if (transaction.HasReachedMaxPatientCount(maximumPatientCount_, hashPatient_)) { storeStatus_ = StoreStatus_StorageFull; - throw OrthancException(ErrorCode_FullStorage, HttpStatus_507_InsufficientStorage, "Maximum patient count reached"); // throw to cancel the transaction + throw OrthancException(ErrorCode_FullStorage, "Maximum patient count reached") // throw to cancel the transaction + .SetHttpStatus(HttpStatus_507_InsufficientStorage); } } else @@ -3015,7 +3017,7 @@ int64_t resourceId; if (!transaction.LookupResource(resourceId, resourceType, publicId_)) { - throw OrthancException(ErrorCode_InexistentItem, HttpStatus_404_NotFound); + throw OrthancException(ErrorCode_InexistentItem).SetHttpStatus(HttpStatus_404_NotFound); } else { diff -r b0402a2b2ddf -r 68001db8ed4a OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Sat Nov 15 10:19:06 2025 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Sat Nov 15 10:24:55 2025 +0100 @@ -855,11 +855,11 @@ case StoreStatus_Failure: LOG(ERROR) << "Unknown store failure while storing instance " << resultPublicId; - throw OrthancException(ErrorCode_InternalError, HttpStatus_500_InternalServerError); + throw OrthancException(ErrorCode_InternalError).SetHttpStatus(HttpStatus_500_InternalServerError); case StoreStatus_StorageFull: LOG(ERROR) << "Storage full while storing instance " << resultPublicId; - throw OrthancException(ErrorCode_FullStorage, HttpStatus_507_InsufficientStorage); + throw OrthancException(ErrorCode_FullStorage).SetHttpStatus(HttpStatus_507_InsufficientStorage); default: // This should never happen