aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-11-17 15:03:35 -0500
committerSean Griffin <sean@seantheprogrammer.com>2016-11-17 15:03:57 -0500
commit7a3be90dce82031952e9abe07d9de7aedf1cb521 (patch)
treec60537125c577f7f3522d894895186057655c283 /activesupport
parent4331ee8390908e52e56cf62b2759a152cddfe1b2 (diff)
downloadrails-7a3be90dce82031952e9abe07d9de7aedf1cb521.tar.gz
rails-7a3be90dce82031952e9abe07d9de7aedf1cb521.tar.bz2
rails-7a3be90dce82031952e9abe07d9de7aedf1cb521.zip
Refactor the handling of fallback exception handlers
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/rescuable.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/rescuable.rb b/activesupport/lib/active_support/rescuable.rb
index 7f29c955f9..e0190fc3b0 100644
--- a/activesupport/lib/active_support/rescuable.rb
+++ b/activesupport/lib/active_support/rescuable.rb
@@ -85,16 +85,16 @@ module ActiveSupport
#
# Returns the exception if it was handled and +nil+ if it was not.
def rescue_with_handler(exception, object: self)
- handler, exception = handler_for_rescue(exception, object: object)
- if handler
+ if handler = handler_for_rescue(exception, object: object)
handler.call exception
exception
+ elsif exception
+ rescue_with_handler(exception.cause, object: object)
end
end
def handler_for_rescue(exception, object: self) #:nodoc:
- rescuer, exception = find_rescue_handler(exception)
- result = case rescuer
+ case rescuer = find_rescue_handler(exception)
when Symbol
method = object.method(rescuer)
if method.arity == 0
@@ -109,7 +109,6 @@ module ActiveSupport
-> e { object.instance_exec(e, &rescuer) }
end
end
- [result, exception]
end
private
@@ -124,11 +123,7 @@ module ActiveSupport
end
end
- if handler
- [handler, exception]
- else
- find_rescue_handler(exception.cause)
- end
+ handler
end
end