# HG changeset patch # User Sebastien Jodogne # Date 1578493333 -3600 # Node ID c1c83c1fb8373bca0a2cba3ac46e30ab1b9849e9 # Parent 7a0460c5e98e4a7903d6180e6315c5777e7932ca GetOrthancImageCommand: handling of unsupported formats diff -r 7a0460c5e98e -r c1c83c1fb837 Framework/Oracle/GetOrthancImageCommand.cpp --- 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(); diff -r 7a0460c5e98e -r c1c83c1fb837 Framework/Oracle/WebAssemblyOracle.cpp --- 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); + } } }