Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 1e848906c594d159da376dc1f41c7869c1f2249e 1 parent 314e2cc
@makimoto makimoto authored
4 actionview/CHANGELOG.md
@@ -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*
View
4 actionview/lib/action_view/template/error.rb
@@ -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
View
7 actionview/test/template/template_error_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.