Skip to content

Catch when a default value raises an exception#51

Merged
jwoertink merged 2 commits intomasterfrom
issues/46
Jun 25, 2020
Merged

Catch when a default value raises an exception#51
jwoertink merged 2 commits intomasterfrom
issues/46

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