diff options
author | Yuki Nishijima <mail@yukinishijima.net> | 2015-11-03 06:54:34 -0800 |
---|---|---|
committer | Yuki Nishijima <mail@yukinishijima.net> | 2015-11-03 06:54:34 -0800 |
commit | 266455cf25aba942b8717ceb0269d66f719b5696 (patch) | |
tree | 702f6aab6d160c722fa85f628c06213be12f7763 /actionpack/lib/action_dispatch/middleware/session | |
parent | d5890bdf660f670271a8f60bd091bd11db4c23b3 (diff) | |
download | rails-266455cf25aba942b8717ceb0269d66f719b5696.tar.gz rails-266455cf25aba942b8717ceb0269d66f719b5696.tar.bz2 rails-266455cf25aba942b8717ceb0269d66f719b5696.zip |
Deprecate exception#original_exception in favor of exception#cause
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/session')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/session/abstract_store.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb index 9e50fea3fc..5fb5953811 100644 --- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb @@ -7,14 +7,22 @@ require 'action_dispatch/request/session' module ActionDispatch module Session class SessionRestoreError < StandardError #:nodoc: - attr_reader :original_exception - def initialize(const_error) - @original_exception = const_error + def initialize(const_error = nil) + if const_error + ActiveSupport::Deprecation.warn("Passing #original_exception is deprecated and has no effect. " \ + "Exceptions will automatically capture the original exception.", caller) + end super("Session contains objects whose class definition isn't available.\n" + "Remember to require the classes for all objects kept in the session.\n" + - "(Original exception: #{const_error.message} [#{const_error.class}])\n") + "(Original exception: #{$!.message} [#{$!.class}])\n") + set_backtrace $!.backtrace + end + + def original_exception + ActiveSupport::Deprecation.warn("#original_exception is deprecated. Use #cause instead.", caller) + cause end end @@ -59,8 +67,8 @@ module ActionDispatch begin # Note that the regexp does not allow $1 to end with a ':' $1.constantize - rescue LoadError, NameError => e - raise ActionDispatch::Session::SessionRestoreError, e, e.backtrace + rescue LoadError, NameError + raise ActionDispatch::Session::SessionRestoreError end retry else |