# HG changeset patch # User Sebastien Jodogne <s.jodogne@gmail.com> # Date 1749656012 -7200 # Node ID 1b3e041cd99bca88fd36acf9fce5e28a4c5aaf50 # Parent dfcac2e0d784c309047110473766834b80b51e4c# Parent 20e44205c2605b0165c473dde3374d997378d654 merge diff -r dfcac2e0d784 -r 1b3e041cd99b NEWS --- a/NEWS Wed Jun 11 17:33:16 2025 +0200 +++ b/NEWS Wed Jun 11 17:33:32 2025 +0200 @@ -20,6 +20,10 @@ In Orthanc 1.12.6 and 1.12.7, "RejectSopClasses" was used instead of the expected "RejectedSopClasses" spelling. * Fix the re-encoding of DICOM files larger than 4GB +* Improved translations of HTTP error codes when a plugin calls the core Rest API. + e.g., a plugin could receive an error 17:OrthancPluginErrorCode_UnknownResource when the underlying + Rest handler was actually returning an HTTP error 415. The plugin will now receive an + error 3000:OrthancPluginErrorCode_UnsupportedMediaType. REST API diff -r dfcac2e0d784 -r 1b3e041cd99b OrthancFramework/Sources/HttpServer/IHttpHandler.cpp --- a/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 17:33:16 2025 +0200 +++ b/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 17:33:32 2025 +0200 @@ -51,7 +51,10 @@ if (handler.Handle(http, origin, LOCALHOST, "", HttpMethod_Get, curi, httpHeaders, getArguments, NULL /* no body for GET */, 0)) { - stream.GetBody(answerBody); + if (stream.GetStatus() == HttpStatus_200_Ok) + { + stream.GetBody(answerBody); + } if (answerHeaders != NULL) { diff -r dfcac2e0d784 -r 1b3e041cd99b OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 17:33:16 2025 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 17:33:32 2025 +0200 @@ -3242,6 +3242,10 @@ { throw OrthancException(ErrorCode_UnknownResource); } + else if (intHttpStatus == 415) + { + throw OrthancException(ErrorCode_UnsupportedMediaType); + } else { throw OrthancException(ErrorCode_BadRequest);