-
Notifications
You must be signed in to change notification settings - Fork 156
Better error handling #544
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
Better error handling #544
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @burrbull (or someone else) soon. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done! Some suggestions.
Tracing would be nice to have, but not necessary to implement right now
Instead of |
Indeed, however some of these functions return syn::Error, so those would have to be changed as well, but that would bring some better usability like |
I integrated most suggestions. Sample output on failure: [INFO svd2rust] Parsing device from SVD file
[INFO svd2rust] Rendering devices
[ERROR svd2rust] Error rendering devices
Caused by:
0: Rendering error at peripheral IRQSEL
Description: Interrupt Selector Peripheral
Group: No group name
1: Issue expanding register or cluster block
2: Error expanding register
Name: PORTA[%s]
Description: PORTA Interrupt Redirect Selection
3: syn error occured
4: Error converting info name PORTA[%s]
5: Determining syn::TypePath from ident "crate::Reg<porta%s::PORTA%S_SPEC>" failed
6: expected `,` |
Looks good! |
I'm tweaking the output a bit: [INFO svd2rust] Parsing device from SVD file
[INFO svd2rust] Rendering devices
[ERROR svd2rust] Error rendering devices
Caused by:
0: Rendering error at peripheral
Name: IRQSEL
Description: Interrupt Selector Peripheral
Group: No group name
1: Issue expanding register or cluster block
2: Error expanding register
Name: PORTA[%s]
Description: PORTA Interrupt Redirect Selection
3: syn error occured
4: Error converting info name PORTA[%s]
5: Determining syn::TypePath from ident "crate::Reg<porta%s::PORTA%S_SPEC>" failed
6: expected `,` |
I think its always just one device which is parsed so I might tweak that output too |
Squash commits, please. |
6581177
to
122b262
Compare
I'll run |
8b3170f
to
e92ea34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Thank you!
bors r+
544: Better error handling r=Emilgardis a=robamu Just a small attempt to make `svd2rust` print more useful information if something goes wrong in the TokenStream generation, or in general - More debug output in case something goes wrong in the TokenStream generation - Some info output in the main I like how the `svd` XML parser handles errors by passing an Error Enum with a node ID up which can be used by one central error handler to print diagnostic information. I don't think it can be done like that here, so I simply print out some locally available information (peripheral name, register name etc.) as the error is propagated Co-authored-by: Robin Mueller <robin.mueller.m@gmail.com>
bors r- Sorry, minor nit |
Canceled. |
- More diagnostic output in case something goes wrong in the TokenStream generation, using `with_context` functions of `anyhow::Result` - Some info output in the main
90e9f9b
to
d534093
Compare
bors r+ |
Build succeeded: |
Just a small attempt to make
svd2rust
print more useful information if something goes wrong in the TokenStream generation, or in generalI like how the
svd
XML parser handles errors by passing an Error Enum with a node ID up which can be used by one central error handler to print diagnostic information. I don't think it can be done like that here, so I simply print out some locally available information (peripheral name, register name etc.) as the error is propagated