In Rails 2 we could override local_request? on the controller, so you had access to a wealth of info to decide whether to show exceptions like the current account, current user, etc.
In Rails 3 that moved to a middleware and the local_request? check moved to the Request itself, which can't see shit.
It'd be great to have a better way to tell ShowExceptions to actually show the exception. It's a patchwork of constructor args, rack env vars, and Request#local? right now. It shouldn't have to know about any of that except a rack env var, ideally.
Leave it up to the controller to tell it whether to kick in or not.
Example: on every request, set env['action_dispatch.show_exceptions'] = show_exceptions? and wrap up the typical local-request checks in a default #show_exceptions? that controllers can override and super to.
env['action_dispatch.show_exceptions'] = show_exceptions?
Targeting 3.2 for a fix. Pull requests welcome!
@jeremy, there are 3 ways in ShowExceptions:
Should we somehow change behaviour of env['action_dispatch.show_exceptions'] or add another one (e.g. env['action_dispatch.rescue_action_locally']) ?
I'll provide pull request for it.
@lest Thanks. It may help to split these into separate middleware, too.
@jeremy I've looked at sinatra sources (it has the same functionalily) and decided:
PS. I've almost done this and added show_exceptions? method to ActionController::Metal (is it ok?), I have to reorganize tests and test it carefully.
Please see pull request #3717
Closed by #3717