-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store original exception in action_dispatch.exception, not exception cause #25623
Store original exception in action_dispatch.exception, not exception cause #25623
Conversation
r? @sgrif (@rails-bot has picked a reviewer for you, use r? to override) |
@sgrif - any thoughts? |
r? @jeremy |
@@ -98,7 +98,7 @@ def call(env) | |||
|
|||
test "calls custom exceptions app" do | |||
exceptions_app = lambda do |env| | |||
assert_kind_of AbstractController::ActionNotFound, env["action_dispatch.exception"] | |||
assert_kind_of ActionView::Template::Error, env["action_dispatch.exception"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#18774 didn't change this assertion; did it really previously contain the outermost exception? 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this case - ActionView::Template::Error
was a special, and used to store the original_exception
(basically its cause
), and ExceptionWrapper
would use this, rather than the outermost exception. We should be fine for it to change now, though. Just put a comment on the PR explaining.
👍 to the change (or something like it), but I'm unsure about compatibility |
Awesome, thanks @matthewd. On compatibility, this change would:
The undesired change in #18774 was that, previously, when anything other than a few Rails-specific errors were raised (grep for The upside of this change is that with it, integrators can get the current behaviour, but without it it's impossible to get back the old behaviour. |
@matthewd any thoughts on the above? |
…cause Previously, when an error was raised that had a cause, we would store the cause of the error in `request.env["action_dispatch.exception"]`, rather than the error itself. That causes a loss of important information - it's not possible to get back to the top-level error from the stored exception (since the `cause` relationship on errors in one-way). After this change, it is the top-level error, rather than its cause, that will be stored in `request.env["action_dispatch.exception"]`. Any exception handler app can then take responsibilty for inspecting the error's cause, if required. Reverses the (undesired) change in behaviour from #18774
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Previously, when an error was raised that had a cause, we would store the cause
of the error in
request.env["action_dispatch.exception"]
, rather than theerror itself. That causes a loss of important information - it's not possible
to get back to the top-level error from the stored exception (since the
cause
relationship on errors in one-way).
After this change, it is the top-level error, rather than its cause, that will
be stored in
request.env["action_dispatch.exception"]
. Any exception handlerapp can then take responsibility for inspecting the error's cause, if required.
Reverses the (undesired?) change in behaviour from
#18774
In our app, there are a bunch of places where we want to avoid serving 422s for validation errors, and instead want to blow up. The recent change to store the exception's
cause
means we can no longer do the following: