File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -284,6 +284,9 @@ def handle_exceptions(e)
284284 }
285285 end
286286
287+ # Store exception for other middlewares
288+ request . env [ 'action_dispatch.exception' ] ||= e
289+
287290 internal_server_error = JSONAPI ::Exceptions ::InternalServerError . new ( e )
288291 Rails . logger . error { "Internal Server Error: #{ e . message } #{ e . backtrace . join ( "\n " ) } " }
289292 errors = internal_server_error . errors
Original file line number Diff line number Diff line change @@ -104,6 +104,21 @@ def test_whitelist_all_exceptions
104104 JSONAPI . configuration . whitelist_all_exceptions = original_config
105105 end
106106
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+
107122 def test_exception_includes_backtrace_when_enabled
108123 original_config = JSONAPI . configuration . include_backtraces_in_errors
109124 $PostProcessorRaisesErrors = true
You can’t perform that action at this time.
0 commit comments