# HG changeset patch # User Alain Mazy # Date 1749652062 -7200 # Node ID 20e44205c2605b0165c473dde3374d997378d654 # Parent 2ab75e4e8c915d0280e1e2d7ef7c1ae8a8f8ed04# Parent ecd7fdc5f8d455c0708ef2f610cadf61f34b2fcf merge diff -r ecd7fdc5f8d4 -r 20e44205c260 NEWS --- a/NEWS Wed Jun 11 15:54:25 2025 +0200 +++ b/NEWS Wed Jun 11 16:27:42 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 ecd7fdc5f8d4 -r 20e44205c260 OrthancFramework/Sources/HttpServer/IHttpHandler.cpp --- a/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 15:54:25 2025 +0200 +++ b/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 16:27:42 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 ecd7fdc5f8d4 -r 20e44205c260 OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 15:54:25 2025 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 16:27:42 2025 +0200 @@ -3242,6 +3242,10 @@ { throw OrthancException(ErrorCode_UnknownResource); } + else if (intHttpStatus == 415) + { + throw OrthancException(ErrorCode_UnsupportedMediaType); + } else { throw OrthancException(ErrorCode_BadRequest);