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

Add new error when int parsing fails #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crozzy
Copy link

@crozzy crozzy commented Oct 9, 2023

It's hard to reason with errors when strconv.ParseUint fails as the returned error is untyped. This change introduces a new error that is returned if the int parsing fails.

It's hard to reason with errors when `strconv.ParseUint` fails as
the returned error is untyped. This change introduces a new error
that is returned if the int parsing fails.

Signed-off-by: crozzy <[email protected]>
@crozzy
Copy link
Author

crozzy commented Oct 9, 2023

I suppose you could also wrap the err returned with %w ie. fmt.Errorf("Error parsing version segment: %w", err), to allow to caller to discern why things failed. It's a weird one because it could also be validated in the regex I suppose but judging by the spec it's not technically an invalid semver.

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 this pull request may close these issues.

1 participant