http_status_exceptions
http_status_exceptions copied to clipboard
Rails log shows Internal Server Error when handling HTTPStatus exceptions
I am throwing an HTTPStatus::BadRequest exception in my controller when a request is invalid. The server correctly replies with a 400 status code and whatever template I give it, but the log in the server console shows:
Started GET "/bla?arg=invalid" for 127.0.0.1 at 2011-08-11 20:14:21 -0400
Processing by BlasController#index as HTML
Parameters: {"arg"=>"invalid"}
Completed 500 Internal Server Error in 1ms
Rendered exceptions/bad_request.html.erb within layouts/application (4.0ms)
So everything is returned correctly, but an incorrect value shows up in the log. It isn't the biggest problem, since as far as the client is concerned, everything is normal. But the log messages aren't very useful, since there's no differentiation between the different kinds of exceptions raised.
Thanks for an awesome yet simple gem!
This sounds like a bug I fixed in Rails (https://github.com/rails/rails/pull/2133). Are you raising that exception inside of a rescue_from block?
I'm using Rails 3.0.9; was your fix included in that? I'm raising the exceptions from the controller, not anything fancy :)
This patch seems to be in the master branch, so it hasn't been released yet and will be part of Rails 3.1. Can you try if the problem persists in Rails master to make sure this is the actual problem?
Got it. I'll try this out when I get a chance.
It should also be in the next release of the 3.0.x branch, so 3.0.10.
Any update on this issue?
@jstorimer's patch was included in the Rails 3.0.10 release. Can you check if it works for you after upgrading? It should be working for 3.1 as well.