[][src]Crate maybe_unwind

A wrapper of catch_unwind that also captures the panic information.

The main purpose of this library is to provide a utility for capturing the error information from assetion macros in custom test libraries.

Example

use maybe_unwind::maybe_unwind;

maybe_unwind::set_hook();

let res: Result<_, maybe_unwind::UnwindContext> = maybe_unwind(|| do_something());
if let Err(err) = res {
    eprintln!("cause: {:?}", err.cause);
    eprintln!("captured: {:?}", err.captured);
}

maybe_unwind::reset_hook();

Structs

CapturedPanicInfo

An information about a panic.

MaybeUnwind

A future for the maybe_unwind method.

UnwindContext

The values captured due to a panic.

Traits

FutureMaybeUnwindExt

An extension trait for Futures that provides an adaptor for capturing the unwinding panic information.

Functions

maybe_unwind

Invokes a closure, capturing the cause of an unwinding panic if one occurs.

reset_hook

Unregisters the custom panic hook and reset the previous hook.

set_hook

Registers the custom panic hook so that the panic information can be captured.