[#13039] exceptions in views give a noisy stack trace
Reported by Chad Humphries | November 19th, 2007 @ 05:02 AM
# 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...
Comments and changes to this ticket
-
Chad Humphries November 19th, 2007 @ 05:02 AM
Date: 2007-08-13 22:06
Sender: Jay Levitt
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.
-
David Chelimsky November 19th, 2007 @ 11:57 AM
- → Assigned user changed from to David Chelimsky
- → State changed from new to open
-
Pat Maddox July 13th, 2008 @ 05:16 AM
- → Tag changed from to bug rails
- → State changed from open to resolved
Somewhere in the last year, the pendulum swung the other way and TemplateErrors got swallowed for the most part. You see a message but no stack trace. Hidden stack trace is fixed in http://github.com/dchelimsky/rsp...
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
