Mercurial > hg > orthanc-stone
diff Framework/Oracle/WebAssemblyOracle.cpp @ 933:f75f6cb69c1b
Commented-out traces for debug
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 26 Jul 2019 20:09:42 +0200 |
parents | 67f9c27214c5 |
children | a7351ad54960 |
line wrap: on
line diff
--- a/Framework/Oracle/WebAssemblyOracle.cpp Wed Jul 24 18:46:25 2019 +0200 +++ b/Framework/Oracle/WebAssemblyOracle.cpp Fri Jul 26 20:09:42 2019 +0200 @@ -153,6 +153,10 @@ **/ std::auto_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData)); + if (fetch->userData == NULL) + { + LOG(ERROR) << "WebAssemblyOracle::FetchContext::SuccessCallback fetch->userData is NULL!!!!!!!"; + } std::string answer; if (fetch->numBytes > 0) @@ -170,12 +174,14 @@ **/ HttpHeaders headers; - if (!context->GetExpectedContentType().empty()) + if (fetch->userData != NULL) { - headers["Content-Type"] = context->GetExpectedContentType(); + if (!context->GetExpectedContentType().empty()) + { + headers["Content-Type"] = context->GetExpectedContentType(); + } } - emscripten_fetch_close(fetch); @@ -394,22 +400,53 @@ void WebAssemblyOracle::Execute(const IObserver& receiver, OrthancRestApiCommand* command) { - FetchCommand fetch(*this, receiver, command); + try + { + //LOG(TRACE) << "*********** WebAssemblyOracle::Execute."; + //LOG(TRACE) << "WebAssemblyOracle::Execute | command = " << command; + FetchCommand fetch(*this, receiver, command); + + fetch.SetMethod(command->GetMethod()); + fetch.SetUri(command->GetUri()); + fetch.SetHttpHeaders(command->GetHttpHeaders()); + fetch.SetTimeout(command->GetTimeout()); + + if (command->GetMethod() == Orthanc::HttpMethod_Post || + command->GetMethod() == Orthanc::HttpMethod_Put) + { + std::string body; + command->SwapBody(body); + fetch.SetBody(body); + } - fetch.SetMethod(command->GetMethod()); - fetch.SetUri(command->GetUri()); - fetch.SetHttpHeaders(command->GetHttpHeaders()); - fetch.SetTimeout(command->GetTimeout()); - - if (command->GetMethod() == Orthanc::HttpMethod_Post || - command->GetMethod() == Orthanc::HttpMethod_Put) + fetch.Execute(); + //LOG(TRACE) << "*********** successful end of WebAssemblyOracle::Execute."; + } + catch (const Orthanc::OrthancException& e) { - std::string body; - command->SwapBody(body); - fetch.SetBody(body); + if (e.HasDetails()) + { + LOG(ERROR) << "OrthancException in WebAssemblyOracle::Execute: " << e.What() << " Details: " << e.GetDetails(); + } + else + { + LOG(ERROR) << "OrthancException in WebAssemblyOracle::Execute: " << e.What(); + } + //LOG(TRACE) << "*********** failing end of WebAssemblyOracle::Execute."; + throw; } - - fetch.Execute(); + catch (const std::exception& e) + { + LOG(ERROR) << "std::exception in WebAssemblyOracle::Execute: " << e.what(); +// LOG(TRACE) << "*********** failing end of WebAssemblyOracle::Execute."; + throw; + } + catch (...) + { + LOG(ERROR) << "Unknown exception in WebAssemblyOracle::Execute"; +// LOG(TRACE) << "*********** failing end of WebAssemblyOracle::Execute."; + throw; + } } @@ -453,14 +490,36 @@ switch (command->GetType()) { case IOracleCommand::Type_OrthancRestApi: + //// DIAGNOSTIC. PLEASE REMOVE IF IT HAS BEEN COMMITTED BY MISTAKE + //{ + // const IObserver* pReceiver = &receiver; + // LOG(TRACE) << "WebAssemblyOracle::Schedule | pReceiver is " << pReceiver; + // LOG(TRACE) << "WebAssemblyOracle::Schedule | command = " << command; + // OrthancRestApiCommand* rac = dynamic_cast<OrthancRestApiCommand*>(protection.get()); + // LOG(TRACE) << "WebAssemblyOracle::Schedule | typed command = " << rac; + // LOG(TRACE) << "WebAssemblyOracle::Schedule" << rac->GetUri(); + //} + //// END OF BLOCK TO REMOVE Execute(receiver, dynamic_cast<OrthancRestApiCommand*>(protection.release())); break; case IOracleCommand::Type_GetOrthancImage: + //// DIAGNOSTIC. PLEASE REMOVE IF IT HAS BEEN COMMITTED BY MISTAKE + //{ + // GetOrthancImageCommand* rac = dynamic_cast<GetOrthancImageCommand*>(protection.get()); + // LOG(TRACE) << "WebAssemblyOracle::Schedule" << rac->GetUri(); + //} + //// END OF BLOCK TO REMOVE Execute(receiver, dynamic_cast<GetOrthancImageCommand*>(protection.release())); break; case IOracleCommand::Type_GetOrthancWebViewerJpeg: + //// DIAGNOSTIC. PLEASE REMOVE IF IT HAS BEEN COMMITTED BY MISTAKE + //{ + // GetOrthancWebViewerJpegCommand* rac = dynamic_cast<GetOrthancWebViewerJpegCommand*>(protection.get()); + // LOG(TRACE) << "WebAssemblyOracle::Schedule" << rac->GetUri(); + //} + //// END OF BLOCK TO REMOVE Execute(receiver, dynamic_cast<GetOrthancWebViewerJpegCommand*>(protection.release())); break;