Function zng::task::wait_catch

source ·
pub async fn wait_catch<T, F>(task: F) -> Result<T, Box<dyn Any + Send>>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Expand description

Like wait but catches panics.

This task works the same and has the same utility as wait, except if returns panic messages as an error instead of propagating the panic.

§Unwind Safety

This function disables the unwind safety validation, meaning that in case of a panic shared data can end-up in an invalid, but still memory safe, state. If you are worried about that only use poisoning mutexes or atomics to mutate shared data or discard all shared data used in the task if this function returns an error.