File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,9 @@ def handle_exceptions(e)
284
284
}
285
285
end
286
286
287
+ # Store exception for other middlewares
288
+ request . env [ 'action_dispatch.exception' ] ||= e
289
+
287
290
internal_server_error = JSONAPI ::Exceptions ::InternalServerError . new ( e )
288
291
Rails . logger . error { "Internal Server Error: #{ e . message } #{ e . backtrace . join ( "\n " ) } " }
289
292
errors = internal_server_error . errors
Original file line number Diff line number Diff line change @@ -104,6 +104,21 @@ def test_whitelist_all_exceptions
104
104
JSONAPI . configuration . whitelist_all_exceptions = original_config
105
105
end
106
106
107
+ def test_exception_added_to_request_env
108
+ original_config = JSONAPI . configuration . whitelist_all_exceptions
109
+ $PostProcessorRaisesErrors = true
110
+ refute @request . env [ 'action_dispatch.exception' ]
111
+ assert_cacheable_get :index
112
+ assert @request . env [ 'action_dispatch.exception' ]
113
+
114
+ JSONAPI . configuration . whitelist_all_exceptions = true
115
+ assert_cacheable_get :index
116
+ assert @request . env [ 'action_dispatch.exception' ]
117
+ ensure
118
+ $PostProcessorRaisesErrors = false
119
+ JSONAPI . configuration . whitelist_all_exceptions = original_config
120
+ end
121
+
107
122
def test_exception_includes_backtrace_when_enabled
108
123
original_config = JSONAPI . configuration . include_backtraces_in_errors
109
124
$PostProcessorRaisesErrors = true
You can’t perform that action at this time.
0 commit comments