Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of HDF5 errors #1585

Closed
wants to merge 1 commit into from
Closed

Improve handling of HDF5 errors #1585

wants to merge 1 commit into from

Conversation

axelboc
Copy link
Contributor

@axelboc axelboc commented Mar 1, 2024

Supersedes #1584 due to some weird issues with GitHub Actions.

Fix #1570

Thanks to @bmaranville and h5wasm@0.7.2, we can now configure the HDF5 library to throw errors instead of just logging them to the console with console.error. This will hopefully help surface bugs much faster (like the one fixed in #1568).

Another benefit is that we can now take advantage of the propagated errors when it makes sense, like when a compression plugin is not supported, instead of trying to detect the situation ahead of time.

Summary of changes:

  • I bump h5wasm and configure HDF5 to throw errors
  • When an error is thrown by HDF5 when reading a dataset's value (or slice):
    • I catch the error and rethrow a more readable error with the original HDF5 error as cause.
    • If one of the diagnostic entries of the HDF5 error relates to a filter not being available, I use that diagnostic message as the message of the rethrown error; otherwise, I use the fallback message "Error detected in HDF5".
  • In ErrorFallback, if an error has a cause, I render a details element with a pre containing the cause. This gives access to the original HDF5 error message for debugging purposes.

Of course, we might uncover other HDF5 errors that we'll need to handle more specifically; this just provides robust foundations. I'm also planning to wrap other h5wasm calls with try/catch (like when reading attributes) in my next PR.

Filter not registered

With dataset sz3 in filters.h5:

Screenshot 2024-03-01 at 11-59-22 H5Web

Screenshot 2024-03-01 at 11-59-12 H5Web

Fallback error

Same file as above, but after commenting out the detection of filter-related errors.

Screenshot 2024-03-01 at 11-57-53 H5Web

No more error for fcidecomp dataset

Before/after screenshots that show that our attempt at predicting when a filter was not supported was causing false positives:

Screenshot 2024-03-01 120023

Screenshot 2024-03-01 at 11-59-41 H5Web

@axelboc axelboc closed this Mar 1, 2024
@axelboc axelboc deleted the hdf5-errors branch March 1, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propage h5wasm errors to viewer
1 participant