-
Notifications
You must be signed in to change notification settings - Fork 18
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
Structural error #43
Comments
I may be going to work on this feature, as it is something I want right now. |
You can find error types in errors.rs files in basic crates. |
@ryo33, |
@jsinger67 That's great! Fortunately or unfortunately, I hadn't started on it yet. |
Ok, fine. Thank you for the quick reply. 👍 |
@ryo33 Edit: I didn't succeed with re-exporting |
Thank you very much. I've created #53 as PoC using your changes. |
I'm not sure if this can work. Maybe this is not optimal but currently I have no idea how to solve this (perhaps by some clever template mechanisms). But I always strive for the simplest solution. I agree with you, that we could achieve good error reporting with other libraries, like codespan or ariadne, which look indeed very promising. I will have a closer look at both of them. |
I think we have a way to do that. #[derive(Error, Debug)]
pub enum ParolError<UserError: std::error::Error> {
#[error(transparent)]
ParserError(#[from] ParserError),
#[error(transparent)]
LexerError(#[from] LexerError),
#[error(transparent)]
UserError(UserError),
} Pros
Cons
|
I've updated #53 with the above idea. The code generation is not updated yet, and it needs a new parameter |
Ok, I see. What I'm rather afraid of is that this could destroy the rapid prototyping behaviour which guarantees that a generated parser works out of the box as an acceptor for its grammar without user written code. I think we should head in this direction. |
How about using |
Instead the generics, |
As a first step we can resort to anyhow::Error for user defined error types. This way the #[from] macro should be able to generate the From trait for it. |
Thank you too! |
@ryo33 I've decided to use codespan_reporting for error reporting in To separate error reporting into a new crate I had to extract In the Maybe I could make this more idiomatic by defining a trait for the reporting and the user reporting plugin function. This will be a next step. Currently I want to bring this error story to a state where we can build on for the foreseeable future. If you have time to have a look at these changes your feedback would be highly appreciated. For the Hihaheho/Desk issue #50 I want to be able to reference a version of Edit: I made error reporting more idiomatic by defining a trait |
@jsinger67 I have subtle suggestions:
|
Yeah, good points 👍 |
I incorporated all your suggestions and now the overall handling is much better. |
Thanks a lot! |
I released new versions on crates.io of |
I think we should have a dedicated error type something like the following instead of
miette::Report
.The text was updated successfully, but these errors were encountered: