How to disable stack-trace shortening?

A

Alexey Verkhovsky

Below is a typical Rails exception thrown from within functional tests.
The interesting part of this exception (test and application code) is
precisely within "... 18 levels..." that are hidden by the interpreter.

Is there any good way to convince Ruby to print full stack trace?

Alex

/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_view/abstract_template.rb:40:in `render_file': ActionView::TemplateError (ActionView::TemplateError)
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/layout.rb:139:in `render'
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/base.rb:269:in `render_action'
from
/../../config/environments/../../app/controllers/person_controller.rb:42:in `create'
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/base.rb:552:in `send'
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/base.rb:552:in `perform_action_without_benchmark'
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/benchmarking.rb:30:in `perform_action_without_filters'
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/benchmarking.rb:30:in `measure'
from
/usr/local/lib/ruby/gems/1.8/gems/actionpack-0.8.5/lib/action_controller/benchmarking.rb:30:in `perform_action_without_filters'
... 18 levels...
from /usr/local/lib/ruby/1.8/test/unit/autorunner.rb:185:in
`run'
from /usr/local/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'
from /usr/local/lib/ruby/1.8/test/unit.rb:283
from /usr/local/lib/ruby/1.8/test/unit.rb:283
 
B

Brian Candler

Below is a typical Rails exception thrown from within functional tests.
The interesting part of this exception (test and application code) is
precisely within "... 18 levels..." that are hidden by the interpreter.

Is there any good way to convince Ruby to print full stack trace?

I had the same issue a couple of years ago, and I ended up grepping through
the interpreter C source for the string "levels..." to find it.

Doing so again... it looks like these are hard-coded constants in eval.c

#define TRACE_HEAD 8
#define TRACE_TAIL 5

So you can change these (and recompile ruby). But I think what I did in the
end was just wrap the code with my own exception catcher, since the full
backtrace array is available to you:

def foo(y)
raise "hell" if y <= 0
foo(y-1)
end

begin
foo(75)
rescue Exception => e
puts "Exception: #{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
exit 1
end

Regards,

Brian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top