Crate error_hook

Source
Expand description

error_hook is a library for automation to insert action at error conversion.

§Example

use error_hook_attr::hook;

#[hook(e => println!("{e}"))]
fn test(a: i32, b: i32) -> error_hook::Result<i32> {
    a.checked_mul(b).ok_or(anyhow::anyhow!("overflow"))
}

fn main() -> anyhow::Result<()> {
    let _ = test(888888888, 888888888);
    //      ^^^^ this prints 'overflow'

    Ok(())
}

Enums§

Error

Traits§

IntoBoxed
 Trait to convert Err type of Result to dynamic trait object.
SameAs
for meta programming

Type Aliases§

Result
Type alias for hook.