controller icon indicating copy to clipboard operation
controller copied to clipboard

Raise error for missing view

Open cllns opened this issue 2 years ago • 1 comments

Before:

view = nil
response.render(view)
# #<NoMethodError: undefined method `call' for nil:NilClass>

After

view = nil
response.render(view)
#<Hanami::Controller::MissingViewError: Cannot render a view that is missing>

We should provide helpful errors to users when possible.

(This came about from implementing the spec for #355)

Happy to change the wording

cllns avatar Nov 12 '21 15:11 cllns

Thanks @jodosha. I just implemented the line you asked for, though I'm not sure it's what you were looking for. I feel like it might make sense to surface the where the Action looked for views, rather than just the name of the class (which will show up in the stacktrace anyway).

Also happy to re-implement the spec in a different way, stubbing out class as a String isn't terrific.

cllns avatar Dec 03 '21 15:12 cllns