Set console error panic hook #17

Open
opened 2024-11-11 09:02:20 +00:00 by Vectornaut · 0 comments
Collaborator

During project setup, I misunderstood this suggestion for how to use the console_error_panic_hook crate. I created a "console_error_panic_hook" feature flag, but I never used it to conditionally compile the code that actually sets the panic hook, which is done here in the example I was following. Many thanks to Luke Chu for catching this!

We can set the panic hook by adding the lines

// set the console error panic hook
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();

at the beginning of main.

During project setup, I misunderstood [this suggestion](https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/template-deep-dive/cargo-toml.html) for how to use the `console_error_panic_hook` crate. I created a "console_error_panic_hook" feature flag, but I never used it to conditionally compile the code that actually sets the panic hook, which is done [here](https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/template-deep-dive/src-utils-rs.html) in the example I was following. Many thanks to Luke Chu for [catching this](https://github.com/sycamore-rs/sycamore/issues/744#issuecomment-2453239332)! We can set the panic hook by adding the lines ``` // set the console error panic hook #[cfg(feature = "console_error_panic_hook")] console_error_panic_hook::set_once(); ``` at the beginning of `main`.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: glen/dyna3#17
No description provided.