cornerstone
cornerstone copied to clipboard
'loadAndCacheImage' not returning error if image file broken
Version I use: "cornerstone-core": "^2.2.7", "cornerstone-tools": "^2.5.0", "cornerstone-wado-image-loader": "^2.2.3"
Issue When the first file to be loaded is broken, 'loadAndCacheImage' is not returning error. As a result, I get the following error from cornerstone-wado-image-loader: "Uncaught (in promise) Error: unsupported pixel format".
What it should do Returning an error so user can catch it and load the next image from a stack.
cornerstone
.loadAndCacheImage(stack.imageId)
.then(image => {
const viewport = cornerstone.getDefaultViewportForImage(
element,
image
);
cornerstone.displayImage(element, image, viewport);
// Set the stack as tool state
cornerstoneTools.addStackStateManager(element, ["stack"]);
})
.catch(err => {
console.log("error: ", err);
});
Thanks for the bug report! A minimal reproduction would go a long way toward a quick verification. I am very open to a test case and PR for this.
EDIT: I made a PR to fix the error that was not caught: https://github.com/cornerstonejs/cornerstoneWADOImageLoader/pull/332
@dannyrb I have reproduced the issue by taking https://rawgit.com/cornerstonejs/cornerstoneWADOImageLoader/master/examples/dicomfile/index.html and saving it as a local page. I then changed loadImage to loadAndCacheImage (although both methods seem to have this issue) and added the following code to the end:
.catch(e=>{ console.error("CAUGHT ERROR:",e); alert("check the console for the error") })
When you select the bad_pixel_data.dcm file from the attached zip, you will notice that the .catch() is never triggered.
The .zip file contains everything you need to reproduce.