Skip to content

Commit

Permalink
Add more helpful error for non-response in Action (#733)
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 74762f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lucky/renderable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ module Lucky::Renderable
response.print
end

private def handle_response(_response : T) forall T
{%
raise <<-ERROR
Your action 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 all conditionals (like if/else) return a response with 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 74762f7

Please sign in to comment.