pub fn set_spawn_panic_handler(
handler: impl FnMut(TaskPanicError) + Send + 'static,
)Expand description
Set a handler that is called when spawn tasks panic.
On panic the tasks spawn, poll_spawn and spawn_wait log an error, notifies the handler and otherwise ignores the panic.
The handler is set for the process lifetime, only handler can be set per app. The handler is called inside the same LocalContext
and thread the task that panicked was called in.
task::set_spawn_panic_handler(|p| {
UPDATES
.run_hn_once(hn_once!(|_| {
std::panic::resume_unwind(p.payload);
}))
.perm();
});The example above shows how to set a handler that propagates the panic to the app main thread.
ยงPanics
Panics if another handler is already set in the same app.
Panics if no app is running in the caller thread.