# HG changeset patch # User Alain Mazy # Date 1749652032 -7200 # Node ID 2ab75e4e8c915d0280e1e2d7ef7c1ae8a8f8ed04 # Parent 255fcf2f8541cabbfceb38bffc1dd42686bda9b7 improved translation of HTTP errors when a plugin calls e.g RestApiGet diff -r 255fcf2f8541 -r 2ab75e4e8c91 NEWS --- a/NEWS Wed Jun 11 14:35:44 2025 +0200 +++ b/NEWS Wed Jun 11 16:27:12 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 255fcf2f8541 -r 2ab75e4e8c91 OrthancFramework/Sources/HttpServer/IHttpHandler.cpp --- a/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 14:35:44 2025 +0200 +++ b/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 16:27:12 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 255fcf2f8541 -r 2ab75e4e8c91 OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 14:35:44 2025 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 16:27:12 2025 +0200 @@ -3242,6 +3242,10 @@ { throw OrthancException(ErrorCode_UnknownResource); } + else if (intHttpStatus == 415) + { + throw OrthancException(ErrorCode_UnsupportedMediaType); + } else { throw OrthancException(ErrorCode_BadRequest);