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

Customize error message reporting #28

Open
ten3roberts opened this issue Dec 5, 2023 · 0 comments
Open

Customize error message reporting #28

ten3roberts opened this issue Dec 5, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ten3roberts
Copy link

Motivation

Currently, errors are logged to the console using console.error. However, it would be useful to provide your own callback for the message, which would allow for using tracing::error instead, which would also enable panics to show in wasm-pack test --node, as well as making it possible for providing your own error screens

Proposed Solution

Provide a new setup function which takes a closure to invoke with the error message, and make the existing set_once use this internally by falling back to console.error

console_error_panic_hook::set_once_with(|msg| tracing::error!("{msg}"));

Alternatives

Making a custom panic hook in place which will contain almost all of this crate's logic, as I have currently done to enable this to work with wasm-pack test and non console environments

@ten3roberts ten3roberts added the enhancement New feature or request label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant