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

Add caused_by to Diagnostic #165

Merged
merged 6 commits into from
May 5, 2022
Merged

Add caused_by to Diagnostic #165

merged 6 commits into from
May 5, 2022

Conversation

matthiasbeyer
Copy link
Contributor

Hi!

Currently, miette does not support error causes which contain a Diagnostic.

This draft tries to change that. It is related to #164 , as I worked with @TheNeikos on implementing this.

Tell me what you think! ❤️


Please note that I will rebase this PR until we all agree on a way forward!

src/handlers/graphical.rs Outdated Show resolved Hide resolved
@matthiasbeyer
Copy link
Contributor Author

For me, tests are green now 🎉

@zkat
Copy link
Owner

zkat commented Apr 29, 2022

Thanks for the patch and the fixes so far! I've continued thinking about this and I'm wondering: How would you feel about renaming caused_by to diagnostic_source? That way, it might be more obvious to people that this is just like '.source(), but for _diagnostics_? caused_bydoesn't tell me much about how it relates tosource`.

@matthiasbeyer
Copy link
Contributor Author

Definitively. Tell me if there's more that you want to have changed. I'll make sure to squash the history appropriately before it gets merged, if it gets merged.

Cargo.toml Outdated
@@ -1,6 +1,6 @@
[package]
name = "miette"
version = "4.6.1-alpha.0"
version = "4.4.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not be in the commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoopsi.

std::option::Option::Some(self.#rel.as_ref())
}
})
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhhh, this shouldn't be unused.

The gen_struct typically generates definitions for when the macro is used on a struct-style error, for example:

#[derive(Diagnostic, Error)]
#[error("meh")]
struct MyError {
  #[diagnostic_source]
  src: SomeError
}

@matthiasbeyer
Copy link
Contributor Author

Okay, I guess now this looks like it is ready ... @zkat if you agree, I can squash and make the history here pretty before it goes in!

@zkat
Copy link
Owner

zkat commented May 3, 2022

you'll want all the tests passing first :)

Copy link
Owner

@zkat zkat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything looks good. I'll merge once tests are passing again :)

Thanks for the contribution, and for hanging in there during the back and forth!

tests/test_diagnostic_source_macro.rs Outdated Show resolved Hide resolved
src/handlers/graphical.rs Outdated Show resolved Hide resolved
@matthiasbeyer
Copy link
Contributor Author

Rebased and squashed everything no be logically grouped into commits. This includes #168 for now, but I am happy to rebase if #168 gets merged.

@zkat zkat merged commit bc449c8 into zkat:main May 5, 2022
@zkat
Copy link
Owner

zkat commented May 5, 2022

yay! Thanks again! :) Looks like we're all set~

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 this pull request may close these issues.

3 participants