Skip to content
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 #5

Closed
TeXitoi opened this issue Feb 7, 2017 · 8 comments
Closed

Better Error handling #5

TeXitoi opened this issue Feb 7, 2017 · 8 comments
Labels
enhancement We would love to have this feature! Feel free to supply a PR

Comments

@TeXitoi
Copy link
Owner

TeXitoi commented Feb 7, 2017

The custom derive should dump great error message instead of just generating dumb code in case of bad usage.

@williamyaoh
Copy link
Contributor

The way I'd want to do this would be to not use syn to parse the input tokens and instead have structopt do its own validation/parsing. syn is already making use of a nom parser, so the idea would be to rip out some code from syn and write a parser to generate data structures specifically for use by structopt. This would also make it easier to write the code generation itself; we wouldn't need asserts sprinkled around and such.

@TeXitoi
Copy link
Owner Author

TeXitoi commented Jul 17, 2017

I think this will be overkill to do that like that.

@TeXitoi TeXitoi added the enhancement We would love to have this feature! Feel free to supply a PR label Sep 1, 2017
Eijebong pushed a commit to Eijebong/structopt that referenced this issue Jan 2, 2019
@CreepySkeleton
Copy link
Collaborator

@TeXitoi
Hi guys, I made a tool exactly for this purpose: https://github.com/CreepySkeleton/proc-macro-error . It should be relatively easy (mostly replace panics with span_error and similar) to integrate and I would do it if you don't mind. What do you think?

@TeXitoi
Copy link
Owner Author

TeXitoi commented Jul 19, 2019

I thought it was now integrated directly in syn, but it seems you know better than me the proc macro ecosystem ;-)

Sure, I'll accept with pleasure. For perfect errors, you might have to change some code around to not loose span information.

@CreepySkeleton
Copy link
Collaborator

For the record: AFAIK syn has nothing to do with error reporting, it's almost entirely about parsing. There is proc_macro::Diagnostics which is for error reporting but is still expiremental.

Just so you know - I am working on this, will make a PR in two days or so

@TeXitoi
Copy link
Owner Author

TeXitoi commented Jul 21, 2019

OK, seeing the span handling from a bit away in syn confused me about that.

I wait for your PR! Thanks!

@CreepySkeleton
Copy link
Collaborator

@TeXitoi By the way, I think we can close this

@TeXitoi
Copy link
Owner Author

TeXitoi commented Aug 21, 2019

Of course. Thanks again.

@TeXitoi TeXitoi closed this as completed Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement We would love to have this feature! Feel free to supply a PR
Projects
None yet
Development

No branches or pull requests

3 participants