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

panic from integer parsing #289

Closed
dimpolo opened this issue May 11, 2024 · 1 comment · Fixed by #291
Closed

panic from integer parsing #289

dimpolo opened this issue May 11, 2024 · 1 comment · Fixed by #291

Comments

@dimpolo
Copy link

dimpolo commented May 11, 2024

When parsing something like:
number = 1000 into a u8 I'm getting:

error: proc-macro derive panicked                                                                                                                                                  
    = help: message: called `Result::unwrap()` on an `Err` value: Error("number too large to fit in target type")

This presumably comes from this unwrap:

Lit::Int(ref s) => Ok(s.base10_parse::<$ty>().unwrap()),

Quoting from the docs:

... darling prefers not to fail on the first error it encounters, instead doing as much work as it can, accumulating errors into a single report.

It would be great to replace the unwrap with the usual error handling

@TedDriggs
Copy link
Owner

Agreed; that should be updated. Not sure why I currently have it panicking.

TedDriggs added a commit that referenced this issue May 13, 2024
Previously, an unwrap was used.
Propagating the error will preserve spans and improve the error message.

This fixes #289
TedDriggs added a commit that referenced this issue May 13, 2024
Previously, an unwrap was used.
Propagating the error will preserve spans and improve the error message.

This fixes #289
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

Successfully merging a pull request may close this issue.

2 participants