allen-cell-animated / volume-viewer

https://allen-cell-animated.github.io/volume-viewer/
Other
92 stars 7 forks source link

Volume load error type #210

Closed frasercl closed 5 months ago

frasercl commented 5 months ago

Review time: medium

Resolves allen-cell-animated/website-3d-cell-viewer#183: makes error handling when loading volumes more consistent, stricter, and more informative.

Adds a new error type: VolumeLoadError. Most (hopefully all) errors that can happen within loaders should now be caught and re-thrown wrapped in this error type, with a more specific and useful error message than the inner error. This error also holds a type field which announces the error's membership in one of a few broad categories (e.g. "no data found," "metadata invalid") so that we can give the user specific guidance about what to do next (e.g. "check that the URL is right," "try regenerating your metadata," "open an issue ticket and tell us to fix our viewer").

Adds a new package: serialize-error allows us to safely send errors from the volume loader worker to the main thread while preserving prototypes and custom properties, ensuring we don't accidentally try to send a buffer or a function or a reference cycle, etc.

Makes some tweaks to volume loading: while I was trying to cover all our error-handling bases, I made some tweaks to the actual behavior of data loading: