Skip to content

Commit

Permalink
Add more helpful error for non-response in Action
Browse files Browse the repository at this point in the history
Part of #460

There is still a bug that makes it so we can't show the type, but I
think we should show this error without the type. It is still better
than what is there.
  • Loading branch information
paulcsmith committed Mar 20, 2019
1 parent 580b28d commit dffbad4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lucky/renderable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ module Lucky::Renderable
response.print
end

private def handle_response(_response : T) forall T
{%
raise <<-ERROR
#{@type} returned #{T}
But it should return a Lucky::Response.
Try this...
▸ Use a method like render/redirect/json at the end of your action.
▸ Ensure conditionals (if/else/case) at the end of your action return a response (render/redirect/json/etc.)
ERROR
%}
end

private def log_response(response : Lucky::Response) : Nil
response.debug_message.try do |message|
Lucky.logger.debug(message)
Expand Down

0 comments on commit dffbad4

Please sign in to comment.