BetterErrors / better_errors

Better error page for Rack apps
MIT License
6.88k stars 437 forks source link

Fix ExceptionWrapper error on manual console page #375

Closed RobinDaugherty closed 7 years ago

RobinDaugherty commented 7 years ago

Starting with Rails 5.0.2 (or possibly earlier) ActionDispatch::ExceptionWrapper will raise an exception undefined method 'cause' for nil:NilClass if a nil exception is passed to it. This is always done when the "manual" page is presented, when the user requests the /__better_errors page. This is the issue in #353.

On Better Errors' "manual" console page, it's not necessary to try to copy the status code from the exception anyway, that only needs to be done when Better Errors is returning an error response caused by the exception.

This fixes the issue by checking for a nil exception and skipping the use of ActionDispatch::ExceptionWrapper in only that case.