dtolnay / dtolnay/anyhow

Short backtrace

Open
#362 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
6.7k
Forks
224
PR merge metrics
No merged PRs in 30d

Description

I have large codebase which uses `anyhow::{Result, Context, bail}` a lot,
and the errors don't tell much. No filename/line numbers at all.
Using `RUST_BACKTRACE=1` is not convenient.

I found https://github.com/dtolnay/anyhow/issues/22 but it will require many changes to add it everywhere.
Is there an elegant way to get short backtrace when error occur, just like we get it with `unwrap()`?

Example:

```rust
use anyhow::{Result, bail};

fn main() -> Result<()> {
job()
}

fn job() -> Result<()> {
bail!("error in job")
}
```

```console
cargo run
Error: error in job
```
Imagine large codebase with many errors coming from internal libraries... no idea where it happens.

Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.