| Crates.io | lerror |
| lib.rs | lerror |
| version | 0.1.1 |
| created_at | 2024-07-04 10:21:50.186435+00 |
| updated_at | 2024-09-03 03:24:59.727594+00 |
| description | A library for creating error types reporting file name, line and column instead of backtrace. |
| homepage | https://github.com/gfreezy/lerror |
| repository | https://github.com/gfreezy/lerror |
| max_upload_size | |
| id | 1291580 |
| size | 66,849 |
Another rust error crate.
Report file name, line and column instead of backtrace.
Most code is copied from anyhow.
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