changeset 4086:4cd94ed75a5b

issue #182: Better handling of errors in plugins reading chunked HTTP body
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 Jun 2020 09:18:30 +0200
parents da06381f3091
children dcf4d83374a6 ce7709cb380e
files NEWS Plugins/Engine/OrthancPlugins.cpp
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Jun 25 15:11:41 2020 +0200
+++ b/NEWS	Fri Jun 26 09:18:30 2020 +0200
@@ -10,6 +10,11 @@
 * New functions in the SDK:
   - new "changes": JobSubmitted, JobSuccess, JobFailure
 
+Maintenance
+-----------
+
+* Issue #182: Better handling of errors in plugins reading chunked HTTP body
+
 
 Version 1.7.1 (2020-05-27)
 ==========================
--- a/Plugins/Engine/OrthancPlugins.cpp	Thu Jun 25 15:11:41 2020 +0200
+++ b/Plugins/Engine/OrthancPlugins.cpp	Fri Jun 26 09:18:30 2020 +0200
@@ -5131,15 +5131,15 @@
         OrthancPluginErrorCode errorCode = handler(
           &reader, matcher.GetFlatUri().c_str(), &converter.GetRequest());
     
-        if (reader == NULL)
+        if (errorCode != OrthancPluginErrorCode_Success)
+        {
+          throw OrthancException(static_cast<ErrorCode>(errorCode));
+        }
+        else if (reader == NULL)
         {
           // The plugin has not created a reader for chunked body
           return false;
         }
-        else if (errorCode != OrthancPluginErrorCode_Success)
-        {
-          throw OrthancException(static_cast<ErrorCode>(errorCode));
-        }
         else
         {
           target.reset(new HttpServerChunkedReader(reader, callback->GetParameters(), GetErrorDictionary()));