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

Return structured errors everywhere #38

Merged
merged 2 commits into from
Jun 8, 2020

Conversation

whatyouhide
Copy link
Collaborator

@whatyouhide whatyouhide commented Jun 7, 2020

Closes #37.

This is a breaking change. Instead of returning {:error, string}, now we return {:error, %NimbleOptions.ValidationError{}} everywhere. For now this error has the message and the path to the failing option but we can change it however we want in the future.

cc @leandrocp @kevinkoltz

{:error, "(in options [:producer]) required option :module not found, received options: [:concurrency]"}
...> {:error, %NimbleOptions.ValidationError{} = error} = NimbleOptions.validate(config, schema)
...> Exception.message(error)
"(in options [:producer]) required option :module not found, received options: [:concurrency]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the path to the end? Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@msaraiva msaraiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@whatyouhide whatyouhide merged commit d066746 into master Jun 8, 2020
@whatyouhide whatyouhide deleted the andrea/use-structured-errors branch June 8, 2020 16:09
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.

Proposal: Support richer error messages
3 participants