I'm attempting to program a browser-based medical image viewer and am using the XTK library to do the heavy lifting. When a file does not load properly (for any number of reasons) I want to let the user know with a pop-up message (eg saying 'File could not be loaded'). From what I can tell though, all the error handling/throwing happens deep down in the loader.js or parser.js files.
More specifically, when I download this file and try loading it with Slicedrop, I get the following error in the console:
Uncaught Error: invalid file signature:
This error is thrown in gunzip.js. At other times, I've had:
Uncaught Error: Loading failed:
thrown in loader.js.
Does anyone know how I could go about catching or passing these errors higher up the chain (ie in JavaScript code like in XTK Tutorial 13?). I've tried the following:
try
sliceX.render();
catch(err)
console.log('ERROR');
But this doesn't catch any errors (due to the asynchronous nature of the file loading I imagine).
The X.renderer has a onShowtime function which is called when all loading has completed. I would imagine a similar function like onLoadError or some other loadingError event?