dtolnay / dtolnay/anyhow

Attach line & file info to anyhow::Error and anyhow::Context

Open
#139 9 comments 47 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
6.7k
Forks
224
PR merge metrics
No merged PRs in 30d

Description

First off, thank you for this wonderful library!

### Context
It's often difficult to find where in your code an error occurred. Rust's backtraces help with this, but are often so verbose that it's still difficult.

### Proposal

It would be great if you could simply glance at the error output to get file and line information. This could be implemented using `#[track_caller]` and can be optionally turned on using a feature flag.

I'm not sure what format you'll want, but I'm imagining something like this:
```
Error: Failed to parse file: hello.txt @ main.rs:7:10

Caused by:
0: Unable to convert this string into a float: '1.5a' @ main.rs:19:24
1: invalid float literal @ main.rs:25:32

Stack backtrace:
...
```

I'm willing to make a PR if you like this feature!

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.