Permalink
Browse files

Merge pull request #12703 from makimoto/actionsupport-error-set_backt…

…race

Use set_backtrace instead of @backtrace in ActionView error
  • Loading branch information...
rafaelfranca committed Nov 16, 2013
2 parents 66f1681 + 1e84890 commit dd184e4b44074a64db27a4ed8c141d26418caef2
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 dd184e4

Please sign in to comment.