diff Plugins/Engine/OrthancPlugins.cpp @ 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 e42f5445d20d
children
line wrap: on
line diff
--- 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()));