Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does the Location section sometimes point inside eyre itself? #46

Closed
TheButlah opened this issue Jan 2, 2021 · 1 comment · Fixed by #48
Closed

Why does the Location section sometimes point inside eyre itself? #46

TheButlah opened this issue Jan 2, 2021 · 1 comment · Fixed by #48

Comments

@TheButlah
Copy link
Contributor

TheButlah commented Jan 2, 2021

Sometimes when using eyre and printing out the error, the location sections points inside of eyre itself instead of the line at which the error occurred. What is the cause of this, and how do I avoid it?

Example error message:

Error: 
   0: Could not open file at "/bogus/path"
   1: No such file or directory (os error 2)

Location:
   /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/eyre-0.6.3/src/context.rs:25

Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Code snippet:

use eyre::{Result, WrapErr};

fn main() -> Result<()> {
    color_eyre::install()?;

    let args = Args::parse();

    let mut reader: Box<dyn Read + Send> = if let Some(ref path) = args.path {
        let reader = std::fs::File::open(path)
            .wrap_err(format!("Could not open file at {:?}", path))?;
        Box::new(reader)
    } else {
        // ....
    };

    //...
}
@yaahc
Copy link
Collaborator

yaahc commented Jan 4, 2021

@TheButlah this is always a bug, and it just means there's a method that can construct another eyre::Report that I missed and need to add #[track_caller] to. There's nothing you can do to avoid it other than report them to me as you see them, so thank you for giving me the heads up ^_^.

#48 should fix it, I should have a new release with the fixes up on crates in just a few minutes.

@yaahc yaahc closed this as completed in #48 Jan 4, 2021
pksunkara pushed a commit that referenced this issue Oct 11, 2023
* change panic example to be consistent with usage example

* bump versions for new release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants