Permalink
Browse files

Use `set_backtrace` instead of `@backtrace` in ActionView error

  • Loading branch information...
1 parent 314e2cc commit 1e848906c594d159da376dc1f41c7869c1f2249e @makimoto makimoto committed Oct 30, 2013
View
@@ -1,3 +1,7 @@
+* Use `set_backtrace` instead of instance variable `@backtrace` in ActionView exceptions
+
+ *Shimpei Makimoto*
+
* Fix `simple_format` escapes own output when passing `sanitize: true`
*Paul Seidemann*
@@ -56,13 +56,13 @@ class Template
class Error < ActionViewError #:nodoc:
SOURCE_CODE_RADIUS = 3
- attr_reader :original_exception, :backtrace
+ attr_reader :original_exception
def initialize(template, original_exception)
super(original_exception.message)
@template, @original_exception = template, original_exception
@sub_templates = nil
- @backtrace = original_exception.backtrace
+ set_backtrace(original_exception.backtrace)
end
def file_name
@@ -6,6 +6,13 @@ def test_provides_original_message
assert_equal "original", error.message
end
+ def test_provides_original_backtrace
+ original_exception = Exception.new
+ original_exception.set_backtrace(%W[ foo bar baz ])
+ error = ActionView::Template::Error.new("test", original_exception)
+ assert_equal %W[ foo bar baz ], error.backtrace
+ end
+
def test_provides_useful_inspect
error = ActionView::Template::Error.new("test", Exception.new("original"))
assert_equal "#<ActionView::Template::Error: original>", error.inspect

0 comments on commit 1e84890

Please sign in to comment.