aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2015-11-03 08:33:46 -0700
committerJeremy Daer <jeremydaer@gmail.com>2015-11-03 08:33:46 -0700
commite670611e6002039231a24d547f9a6e053940fb16 (patch)
tree7acbeba7f649906f8821d7a97412b453cd2c8f3a /actionpack/lib/action_controller
parente4000e3aa78b06bdda39ba0a4d5f1cb5f7d21609 (diff)
parent266455cf25aba942b8717ceb0269d66f719b5696 (diff)
downloadrails-e670611e6002039231a24d547f9a6e053940fb16.tar.gz
rails-e670611e6002039231a24d547f9a6e053940fb16.tar.bz2
rails-e670611e6002039231a24d547f9a6e053940fb16.zip
Merge pull request #18774 from yuki24/deprecate-original-exception-infavor-of-cause
Deprecate exception#original_exception in favor of exception#cause
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal/exceptions.rb15
-rw-r--r--actionpack/lib/action_controller/metal/rescue.rb6
2 files changed, 13 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/metal/exceptions.rb b/actionpack/lib/action_controller/metal/exceptions.rb
index 5260dc0336..5c0ada37be 100644
--- a/actionpack/lib/action_controller/metal/exceptions.rb
+++ b/actionpack/lib/action_controller/metal/exceptions.rb
@@ -3,12 +3,19 @@ module ActionController
end
class BadRequest < ActionControllerError #:nodoc:
- attr_reader :original_exception
-
def initialize(msg = nil, e = nil)
+ if e
+ ActiveSupport::Deprecation.warn("Passing #original_exception is deprecated and has no effect. " \
+ "Exceptions will automatically capture the original exception.", caller)
+ end
+
super(msg)
- @original_exception = e
- set_backtrace e.backtrace if e
+ set_backtrace $!.backtrace if $!
+ end
+
+ def original_exception
+ ActiveSupport::Deprecation.warn("#original_exception is deprecated. Use #cause instead.", caller)
+ cause
end
end
diff --git a/actionpack/lib/action_controller/metal/rescue.rb b/actionpack/lib/action_controller/metal/rescue.rb
index 68cc9a9c9b..81b9a7b9ed 100644
--- a/actionpack/lib/action_controller/metal/rescue.rb
+++ b/actionpack/lib/action_controller/metal/rescue.rb
@@ -7,10 +7,8 @@ module ActionController #:nodoc:
include ActiveSupport::Rescuable
def rescue_with_handler(exception)
- if (exception.respond_to?(:original_exception) &&
- (orig_exception = exception.original_exception) &&
- handler_for_rescue(orig_exception))
- exception = orig_exception
+ if exception.cause && handler_for_rescue(exception.cause)
+ exception = exception.cause
end
super(exception)
end