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

Catch when a default value raises an exception #51

Merged
merged 2 commits into from
Jun 25, 2020
Merged

Conversation

jwoertink
Copy link
Member

Fixes #46

If you set a setting default value to some method you may have written, and that method could raise an exception at some point, then you'll get a weird unexpected error about some recursion stuff. With this PR, we just rescue any possible exceptions, and return nil. This will cause Habitat to raise a MissingSettingError which tells you which setting failed.

… an exception. We catch that and return nil so Habitat will throw the missing setting error. Fixes #46
@jwoertink jwoertink requested a review from paulcsmith June 25, 2020 17:00
Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

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

I can't think of a good way to test this. Maybe add a comment above line 195 that explain it must use the begin so it properly raises errors? Up to you though!

@jwoertink jwoertink merged commit 2097e2d into master Jun 25, 2020
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.

Unexpected error when default value throws an error
2 participants