changeset 1255:c1c83c1fb837 broker

GetOrthancImageCommand: handling of unsupported formats
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 Jan 2020 15:22:13 +0100
parents 7a0460c5e98e
children 8d82baf2afb4
files Framework/Oracle/GetOrthancImageCommand.cpp Framework/Oracle/WebAssemblyOracle.cpp
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Oracle/GetOrthancImageCommand.cpp	Wed Jan 08 14:01:36 2020 +0100
+++ b/Framework/Oracle/GetOrthancImageCommand.cpp	Wed Jan 08 15:22:13 2020 +0100
@@ -84,6 +84,19 @@
                                                  const std::string& answer,
                                                  const HttpHeaders& answerHeaders) const
   {
+    for (HttpHeaders::const_iterator it = answerHeaders.begin(); it != answerHeaders.end(); ++it)
+    {
+      std::string key = Orthanc::Toolbox::StripSpaces(it->first);
+      Orthanc::Toolbox::ToLowerCase(key);
+        
+      if (key == "content-disposition" &&
+          it->second == "filename=\"unsupported.png\"")
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat,
+                                        "Orthanc cannot decode this image");
+      }
+    }
+    
     Orthanc::MimeType contentType = Orthanc::MimeType_Binary;
 
     for (HttpHeaders::const_iterator it = answerHeaders.begin(); 
--- a/Framework/Oracle/WebAssemblyOracle.cpp	Wed Jan 08 14:01:36 2020 +0100
+++ b/Framework/Oracle/WebAssemblyOracle.cpp	Wed Jan 08 15:22:13 2020 +0100
@@ -310,12 +310,18 @@
             default:
               LOG(ERROR) << "Command type not implemented by the WebAssembly Oracle (in SuccessCallback): "
                          << context->GetCommand().GetType();
+              throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
           }
         }
       }
       catch (Orthanc::OrthancException& e)
       {
-        LOG(ERROR) << "Error while processing a fetch answer in the oracle: " << e.What();
+        LOG(INFO) << "Error while processing a fetch answer in the oracle: " << e.What();
+
+        {
+          OracleCommandExceptionMessage message(context->GetCommand(), e);
+          context->EmitMessage(message);
+        }
       }
     }