Skip to main content

caught

Function caught 

Source
pub async fn caught<T>(
    operation: &'static str,
    work: impl Future<Output = T>,
) -> Result<T, Bug>
Expand description

Run work inline, catching a panic in any of its polls. For one message of a long-lived loop: the panic fails that message and the loop serves the next. Run inline, the work can’t be dropped by its runtime, so a panic is its only failure.

After a panic work is dropped at once, inside a catch of its own, so a drop that panics on what the first panic left behind does not unwind into the caller either.