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

Provide better error message when field attribute is incorrect #44

Open
Kriskras99 opened this issue Nov 1, 2024 · 1 comment
Open

Comments

@Kriskras99
Copy link
Contributor

I got this error message:

error: custom attribute panicked
  --> ubiart_toolkit/src/cooked/isg/mod.rs:18:1
   |
18 | #[superstruct(variants(V22, V21, V20, V20C, V19, V18, V17, V16))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: Error { kind: UnknownField(ErrorUnknownField { name: "V19", did_you_mean: None }), locations: [], span: Some(#0 bytes(619472..619475)) }

which was because I had a field attribute [superstruct(V19)] instead of [superstruct(only(V19))]. It would be nice of the error message detected that the field name is also an attribute and suggests only and any other relevant attributes.
If it could also give the line number that would be even better.

@michaelsproul
Copy link
Member

Sorry yeah the error messages in superstruct have not received any polish, so there are a lot of cases like this where we will just crash.

If I find some time I'll try threading the errors and spans around to see if that improves things. It should!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants