-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Render diagnostics without exiting? #384
Comments
Try |
That doesn't seem to do the trick. Just to be concrete, let's say I have this type: #[derive(Debug, Error, Diagnostic)]
#[error("Invalid manifest")]
#[diagnostic(
code("manifest::parse"),
url("http://example.com"),
help("Please check the documentation for the correct format.")
)]
pub struct InvalidManifest {
#[source_code]
pub manifest_contents: String,
#[label = "here"]
pub span: SourceSpan,
} If I construct that manually and try printing it with let err = InvalidManifest {...};
eprintln!("{:?}", err); I get the debug representation of the eprintln!("{}", err); I only see I can also call |
@zmitchell you're not calling |
I see, I guess I was confused why I needed to call |
Yeah I guess the naming is weird. What it actually does it get you a |
I also found this exceptionally hard to find. I also got a lot of I eventually resorted to:
That worked. |
Say I have a user editing a file and if it doesn’t parse to the correct format I want to display the error and ask if they’d like to try again. Essentially we have an edit loop that runs until they get it right or quit. How do I get miette to render the error on each loop iteration?
I’ve tried just using
println!
, but only theerror(…)
annotation is displayed (no snippet, etc). I’ve checked that the span and source code are as expected. I checked which type of report handler is being used, and it’s not the graphical handler, though it also seems like I don’t have a way to force one to be used.Any advice?
The text was updated successfully, but these errors were encountered: