[rspec-devel] [ rspec-Bugs-13039 ] exceptions in views give a noisy stack trace
noreply at rubyforge.org
noreply at rubyforge.org
Mon Aug 13 22:06:04 EDT 2007
Bugs item #13039, was opened at 2007-08-13 21:32
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=13039&group_id=797
Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Jay Levitt (jaylev)
Assigned to: Nobody (None)
Summary: exceptions in views give a noisy stack trace
Initial Comment:
# spec/views/bad_spec.rb
require File.dirname(__FILE__) + '/../../spec_helper'
describe "test" do
it "test" do
m = mock("test")
assigns[:m] = m
render '/users/test'
end
end
# app/views/user/test.html.erb
<% @m.blah %>
Result: The stack trace isn't cleaned by backtrace_tweaker, because instead of e.backtrace being an array of strings, each with one line, it's an array with one element - all the lines of the backtrace concatenated with "\n" separators.
I cannot figure out where this is happening. The exception as re-raised by ActionView::Base#render_file still has a proper array, but by the time it gets to Spec::DSL::Example#run_example, it's a single-element array. I don't know enough about exceptions to know how to find every rescue/re-raise of the exception...
----------------------------------------------------------------------
>Comment By: Jay Levitt (jaylev)
Date: 2007-08-13 22:06
Message:
OK, a little set_trace_func and now I get it. When
ActionView::Base#render_file reraises the exception, it's
actually setting the backtrace to template_source, which I
guess must come from ERB, and which is newline-separated.
However, it changes the exception type to TemplateError, and
stashes the original exception in e.original_exception.
So we could do a few things:
1. Parse the newlines out if this is a TemplateError.
2. Look at e.original_exception.backtrace instead of
e.backtrace if this is a TemplateError.
3. Some combination of the two. That'd only be necessary if
the two backtraces could ever differ; I have no idea if that
could happen or not.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=13039&group_id=797
More information about the rspec-devel
mailing list