Permalink
Browse files

Ensure original exception message is present in both Template::Error#…

…message and Template::Error#inspect.

Previously, #inspect would produce #<ActionView::Template::Error: ActionView::Template::Error>, which is not very useful.
  • Loading branch information...
1 parent 7bbad75 commit 403b06e98ee88b96b6fbd8692f072fdfa7857639 John Firebaugh committed with John Firebaugh Sep 25, 2010
Showing with 14 additions and 4 deletions.
  1. +1 −4 actionpack/lib/action_view/template/error.rb
  2. +13 −0 actionpack/test/template/template_error_test.rb
@@ -52,6 +52,7 @@ class Error < ActionViewError #:nodoc:
attr_reader :original_exception, :backtrace
def initialize(template, assigns, original_exception)
+ super(original_exception.message)
@template, @assigns, @original_exception = template, assigns.dup, original_exception
@sub_templates = nil
@backtrace = original_exception.backtrace
@@ -61,10 +62,6 @@ def file_name
@template.identifier
end
- def message
- original_exception.message
- end
-
def sub_template_message
if @sub_templates
"Trace of template inclusion: " +
@@ -0,0 +1,13 @@
+require "abstract_unit"
+
+class TemplateErrorTest < ActiveSupport::TestCase
+ def test_provides_original_message
+ error = ActionView::Template::Error.new("test", {}, Exception.new("original"))
+ assert_equal "original", error.message
+ end
+
+ def test_provides_useful_inspect
+ error = ActionView::Template::Error.new("test", {}, Exception.new("original"))
+ assert_equal "#<ActionView::Template::Error: original>", error.inspect
+ end
+end

0 comments on commit 403b06e

Please sign in to comment.