-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
#[diagnostic(transparent)]
for passthrough diagnostics
#16
Comments
actuallly I don't think we need this, if we have |
@zkat This is still necessary. Just placing Thiserror does give you the From implementation via The use case for miette is pretty obvious, same as thiserror's, but for some context, I'm doing this: #[derive(Debug, Error, Diagnostic)]
enum Diag {
#[error(transparent)] #[diagnostic(transparent)] Error(#[from] Error),
// The rest of the variants go here, all warnings/advice, no errors
}
// this would be weird -- you could fail your whole thing because of a warning
fn bad_function(...) -> Result<i32, Diag> {}
// this way your Err case is never a warning, so you are never in the situation where
// there is only a warning but you don't have an Ok value to continue with
fn better_function(...) -> Result<i32, Error> {} |
There is another way, which is to box all of your diagnostics and let the dynamism do the work. But sometimes you don't want to erase all the types, if you're like me (the guy from twitter who wanted to collect all the diagnostics into a Vec and expose them to library users) then maybe you just want the one type. The You might also want to delegate only some of the Diagnostic implementation. I'm thinking about having a lot of different variants where practically every single one has a source, a snippet and an optional hint. Being able to forward the snippet implementation to a single |
I'm having a crack at a PR for this |
No description provided.
The text was updated successfully, but these errors were encountered: