aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-02-28 15:39:08 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-02-28 15:39:08 -0800
commita7b059ec7f25c16beeacf2c545d2be593ed0388b (patch)
tree44c680aeecbee5ddb8dc05882779c8fe4b5baa4a /actionpack/lib
parent30d21dfcb7fafe49b3805b8249454485a90097b6 (diff)
downloadrails-a7b059ec7f25c16beeacf2c545d2be593ed0388b.tar.gz
rails-a7b059ec7f25c16beeacf2c545d2be593ed0388b.tar.bz2
rails-a7b059ec7f25c16beeacf2c545d2be593ed0388b.zip
use built-in exception handling in live controllers
when an exception happens in an action before the response has been committed, then we should re-raise the exception in the main thread. This lets us reuse the existing exception handling.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/live.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb
index fba17746c0..d60f1b0d44 100644
--- a/actionpack/lib/action_controller/metal/live.rb
+++ b/actionpack/lib/action_controller/metal/live.rb
@@ -203,6 +203,7 @@ module ActionController
t1 = Thread.current
locals = t1.keys.map { |key| [key, t1[key]] }
+ error = nil
# This processes the action in a child thread. It lets us return the
# response code and headers back up the rack stack, and still process
# the body in parallel with sending data to the client
@@ -217,8 +218,9 @@ module ActionController
begin
super(name)
rescue => e
- @_response.status = 500 unless @_response.committed?
- @_response.status = 400 if e.class == ActionController::BadRequest
+ unless @_response.committed?
+ error = e
+ end
begin
@_response.stream.write(ActionView::Base.streaming_completion_on_exception) if request.format == :html
@_response.stream.call_on_error
@@ -234,6 +236,7 @@ module ActionController
}
@_response.await_commit
+ raise error if error
end
def log_error(exception)