Mercurial > hg > orthanc
changeset 6167:2ab75e4e8c91
improved translation of HTTP errors when a plugin calls e.g RestApiGet
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Wed, 11 Jun 2025 16:27:12 +0200 |
parents | 255fcf2f8541 |
children | 20e44205c260 |
files | NEWS OrthancFramework/Sources/HttpServer/IHttpHandler.cpp OrthancServer/Plugins/Engine/OrthancPlugins.cpp |
diffstat | 3 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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) {
--- 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);