Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Capture view errors in ActionView::Template.

This means that errors raised by partials are caught by ActionView::PartialTemplate,
which in turn means they have the proper filename and line number information.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit b88a6dbc39fcaa12dc58d06d4222f2443f02a32a 1 parent f6ec296
@nex3 nex3 authored lifo committed
View
13 actionpack/lib/action_view/base.rb
@@ -244,16 +244,7 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc
template = Template.new(self, template_path, use_full_path, local_assigns)
- begin
- render_template(template)
- rescue Exception => e
- if TemplateError === e
- e.sub_template_of(template.filename)
- raise e
- else
- raise TemplateError.new(template, @assigns, e)
- end
- end
+ render_template(template)
end
# Renders the template present at <tt>template_path</tt> (relative to the view_paths array).
@@ -290,7 +281,7 @@ def render(options = {}, local_assigns = {}, &block) #:nodoc:
end
def render_template(template) #:nodoc:
- template.render
+ template.render_template
end
# Returns true is the file may be rendered implicitly.
View
2  actionpack/lib/action_view/partial_template.rb
@@ -24,7 +24,7 @@ def render
def render_member(object)
@locals[@counter_name] += 1
@locals[:object] = @locals[@variable_name] = object
- returning render do
+ returning render_template do
@locals.delete(@variable_name)
@locals.delete(:object)
end
View
2  actionpack/lib/action_view/partials.rb
@@ -107,7 +107,7 @@ def render_partial(partial_path, object_assigns = nil, local_assigns = {}) #:nod
case partial_path
when String, Symbol, NilClass
# Render the template
- ActionView::PartialTemplate.new(self, partial_path, object_assigns, local_assigns).render
+ ActionView::PartialTemplate.new(self, partial_path, object_assigns, local_assigns).render_template
when ActionView::Helpers::FormBuilder
builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '')
render_partial(builder_partial_path, object_assigns, (local_assigns || {}).merge(builder_partial_path.to_sym => partial_path))
View
12 actionpack/lib/action_view/template.rb
@@ -17,6 +17,18 @@ def initialize(view, path, use_full_path, locals = {})
@locals = locals || {}
@handler = self.class.handler_class_for_extension(@extension).new(@view)
end
+
+ def render_template
+ render
+ rescue Exception => e
+ raise e unless filename
+ if TemplateError === e
+ e.sub_template_of(filename)
+ raise e
+ else
+ raise TemplateError.new(self, @view.assigns, e)
+ end
+ end
def render
prepare!
Please sign in to comment.
Something went wrong with that request. Please try again.