Mercurial > hg > orthanc-stone
changeset 995:9893fa8cd7a6
send error message for HTTP fetching in wasm
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 14 Sep 2019 17:27:41 +0200 |
parents | 1f74bc3459ba |
children | 727f2007ca23 38b6bb0bdd72 |
files | Framework/Oracle/WebAssemblyOracle.cpp |
diffstat | 1 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Oracle/WebAssemblyOracle.cpp Thu Sep 12 08:27:12 2019 +0200 +++ b/Framework/Oracle/WebAssemblyOracle.cpp Sat Sep 14 17:27:41 2019 +0200 @@ -22,6 +22,7 @@ #include "WebAssemblyOracle.h" #include "SleepOracleCommand.h" +#include "OracleCommandExceptionMessage.h" #include <Core/OrthancException.h> #include <Core/Toolbox.h> @@ -352,19 +353,27 @@ static void FailureCallback(emscripten_fetch_t *fetch) { std::auto_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData)); - - const size_t kEmscriptenStatusTextSize = sizeof(emscripten_fetch_t::statusText); - char message[kEmscriptenStatusTextSize + 1]; - memcpy(message, fetch->statusText, kEmscriptenStatusTextSize); - message[kEmscriptenStatusTextSize] = 0; + + { + const size_t kEmscriptenStatusTextSize = sizeof(emscripten_fetch_t::statusText); + char message[kEmscriptenStatusTextSize + 1]; + memcpy(message, fetch->statusText, kEmscriptenStatusTextSize); + message[kEmscriptenStatusTextSize] = 0; - LOG(ERROR) << "Fetching " << fetch->url - << " failed, HTTP failure status code: " << fetch->status - << " | statusText = " << message - << " | numBytes = " << fetch->numBytes - << " | totalBytes = " << fetch->totalBytes - << " | readyState = " << fetch->readyState; + LOG(ERROR) << "Fetching " << fetch->url + << " failed, HTTP failure status code: " << fetch->status + << " | statusText = " << message + << " | numBytes = " << fetch->numBytes + << " | totalBytes = " << fetch->totalBytes + << " | readyState = " << fetch->readyState; + } + { + OracleCommandExceptionMessage message + (context->GetCommand(), Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol)); + context->EmitMessage(message); + } + /** * TODO - The following code leads to an infinite recursion, at * least with Firefox running on incognito mode => WHY?