Only use DidYouMean-integrated Error for Component loading failure #261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Without this, any NameError (including NoMethodError) will go through the DidYouMean integration and
it will fail since that code expects only a Constant, not any name (including "undefined local variable or method")
Instead, this code will ensure we only try to do that when we get a NameError for specifically trying to load the constant we're looking for. Everything else will be re-raised and go through the normal flow (including any more DidYouMean default behavior).
Fixes hanami/hanami#1252. (Specifically see this comment)
Bug introduced in #217
Thoughts on whether we should test this? We could create a fixture file to load a component that has a NameError in it and ensure that error passes through instead of getting created as a
ComponentNotLoadableError
... but that would error out anyway. Creating a NameError in the spec just raises that before we can even get to the example.I manually confirmed that it works with the repo @katafrakt created to illustrate the bug.