Crates.io | anyhow-auto-context |
lib.rs | anyhow-auto-context |
version | |
source | src |
created_at | 2025-01-10 07:59:02.427567+00 |
updated_at | 2025-01-10 07:59:02.427567+00 |
description | Automatic context for anyhow errors based on scope and location |
homepage | |
repository | https://github.com/imbolc/anyhow-auto-context |
max_upload_size | |
id | 1511027 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Automatic context for anyhow errors based on scope and location.
Option
use anyhow_auto_context::auto_context;
fn main() -> anyhow::Result<()> {
let expected_some = None;
auto_context!(expected_some)
}
$ cargo run --example option
Error: expected_some in option::main at examples/option.rs:6:5
Result
use anyhow::Result;
use anyhow_auto_context::auto_context;
fn main() -> Result<()> {
auto_context!(foo())
}
fn foo() -> Result<()> {
auto_context!(bar())
}
fn bar() -> Result<()> {
anyhow::bail!("my error")
}
$ cargo run --example result
Error: foo() in result::main at examples/result.rs:6:5
Caused by:
0: bar() in result::foo at examples/result.rs:10:5
1: my error
please run .pre-commit.sh before sending a PR, it will check everything
This project is licensed under the MIT license.