-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Help: Sub Errors #364
Comments
That's done through the standard Additionally, in order to have those sub-errors get the miette treatment themselves, you can use A full example: use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Error, Diagnostic)]
struct JsonError {
#[source]
#[source_diagnostic]
inner: SerdeJsonErrorWrapper
}
#[derive(Debug, Error, Diagnostic)]
struct SerdeJsonErrorWrapper(#[from] serde_json::Error); (I've added an unnecessary indirection just to show |
Thank you for your patience, that answers my question! Also, Is there a way to set the diagnostic code from with a variable in the sturct? Or can you inherit a code from structure in a field? |
Not with the current derive macro. You'd have to implement |
In the readme file an example is shown of multiple sub errors being rendered under the main error message. How can I replicate this behavior?
The text was updated successfully, but these errors were encountered: