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

[Bug] Different behavior when hooking the Context on stable vs. nightly #1092

Closed
TimDiekmann opened this issue Sep 26, 2022 · 0 comments · Fixed by #1102
Closed

[Bug] Different behavior when hooking the Context on stable vs. nightly #1092

TimDiekmann opened this issue Sep 26, 2022 · 0 comments · Fixed by #1102
Assignees
Labels
area/libs > error-stack Affects the `error-stack` crate (library) category/bug Something isn't working

Comments

@TimDiekmann
Copy link
Member

TimDiekmann commented Sep 26, 2022

Describe the bug

On stable, downcast_ref is used for the hooks, on nightly request_ref and request_value is used. For attachments, this is the same as attachments only provide themself, but for contexts do not provide themself. When installing a hook for e.g. io::Error and use io::Error as context, the output is different:

stable:

invalid input parameter
├╴test.rs:10:18
╰╴invalid input parameter

nightly:

invalid input parameter
╰╴test.rs:10:18

To reproduce

use std::io::{Error, ErrorKind};

use error_stack::Report;

fn main() {
    Report::install_debug_hook::<Error>(|error, ctx| {
        ctx.push_body(error.to_string());
    });

    let report = Report::new(Error::from(ErrorKind::InvalidInput));

    println!("{report:?}");
}

Expected behavior

The output should be the same and stable and on nightly.

Rust compiler

1.63 and 1.65.0-nightly (2022-08-26)

Host

aarch64-apple-darwin

Target

aarch64-apple-darwin

Version

cf5d85e

Features

all

Additional context

As a Context does not provide itself, the same behavior should be emulated on stable as well. As provisioning is not supported on stable, a Context frame can simply be ignored.

The other solution would be to provide the context frame as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/libs > error-stack Affects the `error-stack` crate (library) category/bug Something isn't working
Development

Successfully merging a pull request may close this issue.

4 participants