anyhow-loc

Crates.ioanyhow-loc
lib.rsanyhow-loc
version0.3.0
sourcesrc
created_at2024-09-15 10:47:11.25865
updated_at2024-09-15 10:55:53.136769
descriptionanyhow with location
homepage
repositoryhttps://github.com/qyuzh/anyhow-loc
max_upload_size
id1375373
size5,561
qyuzh (qyuzh)

documentation

https://docs.rs/anyhow-loc

README

anyhow location

Error with location

use anyhow_loc::{msg, ErrorLocation};

fn f() -> anyhow::Result<()> {
    anyhow::bail!("oh no!");
}

fn main() -> anyhow::Result<()> {
    let t = String::from("error 2");
    f().with_location(|| msg!("error")) // sep
        .with_location(|| msg!("{}", t))?;
    Ok(())
}

Output

Error: error 2 
 at examples/basic.rs:10

Caused by:
    0: error 
        at examples/basic.rs:9
    1: oh no!
Commit count: 0

cargo fmt