[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to disable stack-trace shortening?

Alexey Verkhovsky

10/10/2004 11:02:00 AM

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




1 Answer

Brian Candler

10/10/2004 11:12:00 AM

0

On Sun, Oct 10, 2004 at 08:02:20PM +0900, Alexey Verkhovsky wrote:
> 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.