#line-column #filename #file-line #backtrace #name #reporting #report

lerror

A library for creating error types reporting file name, line and column instead of backtrace

2 releases

0.1.1 Sep 3, 2024
0.1.0 Jul 4, 2024

#636 in Debugging

Download history 134/week @ 2024-08-28 41/week @ 2024-09-04 15/week @ 2024-09-11 20/week @ 2024-09-18 11/week @ 2024-09-25 3/week @ 2024-10-02 1/week @ 2024-10-09 1/week @ 2024-10-16

99 downloads per month

MIT license

65KB
1K SLoC

lerror

Another rust error crate.

Report file name, line and column instead of backtrace.

Most code is copied from anyhow.

Usage

use lerror::{bail, Context, ContextExt, Result};

#[test]
fn a() -> Result<()> {
    b().c()?;  // You need to call `c()` to add the current line to backtrace without context. Or you can call `context()` to add string context.
    bail!("permission denied for accessing {}", "resource");
    Ok(())
}

fn b() -> Result<()> {
    c().context("File not found")?;
    bail!("File not found");
}

fn c() -> Result<()> {
    bail!("Image not found");
}

Output:

Error: lerror::Error

    0: tests/test.rs:5:9
    1: tests/test.rs:11:9
       File not found
    2: tests/test.rs:16:5
       Image not found

No runtime deps