Skip to main content

setup_panic_handler

Function setup_panic_handler 

Source
pub fn setup_panic_handler()
Expand description

Sets up a custom panic hook for the application with advanced features.

This function configures panic behavior based on the build profile:

  • Debug builds: Uses better_panic for verbose, immediate, and diagnostic-rich panics with full stack traces.
  • Release builds: Uses human_panic for graceful, user-friendly panics that log internally without exposing sensitive details, prioritizing user experience.

Additionally, it provides a mechanism to catch panics from spawned Tokio tasks.

This function should be called only once. Subsequent calls will be ignored.