diff Framework/Oracle/WebAssemblyOracle.cpp @ 959:13e078adfb94 toa2019082301

Better error log in fetch failure callback + timeout 600sec in OrthancRestApiCommand + guard against dead controller access in PanSceneTracker + relaxed DicomStructureSet AddReferenceSlice method to accept extraneous adds of the same slice (while trying to understand how it happens in the first place)
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 23 Aug 2019 14:16:45 +0200
parents a7351ad54960
children 91f827272c1f
line wrap: on
line diff
--- a/Framework/Oracle/WebAssemblyOracle.cpp	Fri Aug 23 10:16:32 2019 +0200
+++ b/Framework/Oracle/WebAssemblyOracle.cpp	Fri Aug 23 14:16:45 2019 +0200
@@ -237,13 +237,23 @@
     {
       std::auto_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData));
       
-      LOG(ERROR) << "Fetching " << fetch->url << " failed, HTTP failure status code: " << fetch->status;
+      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;
 
       /**
        * TODO - The following code leads to an infinite recursion, at
        * least with Firefox running on incognito mode => WHY?
        **/      
-      //emscripten_fetch_close(fetch); // Also free data on failure.
+      emscripten_fetch_close(fetch); // Also free data on failure.
     }
   };