提交 976e7e44 编写于 作者: A Aaron Patterson

* move exception message to exception constructor

* save original exception
* keep original backtrace
上级 ae8f4974
...@@ -7,6 +7,15 @@ ...@@ -7,6 +7,15 @@
module ActionDispatch module ActionDispatch
module Session module Session
class SessionRestoreError < StandardError #:nodoc: class SessionRestoreError < StandardError #:nodoc:
attr_reader :original_exception
def initialize(const_error)
@original_exception = const_error
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")
end
end end
module DestroyableSession module DestroyableSession
...@@ -58,11 +67,8 @@ def stale_session_check! ...@@ -58,11 +67,8 @@ def stale_session_check!
begin begin
# Note that the regexp does not allow $1 to end with a ':' # Note that the regexp does not allow $1 to end with a ':'
$1.constantize $1.constantize
rescue LoadError, NameError => const_error rescue LoadError, NameError => e
raise ActionDispatch::Session::SessionRestoreError, raise ActionDispatch::Session::SessionRestoreError, e, e.backtrace
"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"
end end
retry retry
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册