From 3f93888808442c014eab31ba31151daeafa76f1f Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Wed, 23 Dec 2015 17:14:12 +0200 Subject: Fix edge case with ActionView::Template::Error reraise When you re-raise an ActionView::Template::Error, the #cause can change. You can see this behaviour with [nack]. Currently, `web-console` doesn't run the console in the proper binding in the case of errors in the views, because when we follow the `#cause` of the exception it is an [`EOFError`][EOFError]. This also affects [pow] as it runs on [nack]. [nack]: https://github.com/josh/nack [pow]: http://pow.cx/ [EOFError]: https://github.com/josh/nack/blob/d523cc870c0a11dcf349388a15adfecba9314f97/lib/nack/server.rb#L108 --- actionview/lib/action_view/template/error.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionview/lib/action_view/template/error.rb') diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb index b03b197cb5..ccee785d3e 100644 --- a/actionview/lib/action_view/template/error.rb +++ b/actionview/lib/action_view/template/error.rb @@ -59,6 +59,9 @@ module ActionView class Error < ActionViewError #:nodoc: SOURCE_CODE_RADIUS = 3 + # Override to prevent #cause resetting during re-raise. + attr_reader :cause + def initialize(template, original_exception = nil) if original_exception ActiveSupport::Deprecation.warn("Passing #original_exception is deprecated and has no effect. " \ @@ -67,6 +70,7 @@ module ActionView super($!.message) set_backtrace($!.backtrace) + @cause = $! @template, @sub_templates = template, nil end -- cgit v1.2.3