entire stack trace

E

Eric Mahurin

When the stack is deep and you get an exception, you get
something like this in the middle of the stack trace:

... 20 levels ...

Is there any way to get the entire trace?


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around=20
http://mail.yahoo.com=20
 
P

Pit Capitain

Eric said:
When the stack is deep and you get an exception, you get
something like this in the middle of the stack trace:

... 20 levels ...

Is there any way to get the entire trace?

Catch the exception and print its backtrace

begin
call_deeply_nested_method
rescue Exception => ex
puts ex, ex.backtrace
end

Regards,
Pit
 
E

Eric Mahurin

--- Pit Capitain said:
=20
Catch the exception and print its backtrace
=20
begin
call_deeply_nested_method
rescue Exception =3D> ex
puts ex, ex.backtrace
end

I already figured out that one. Any way to override the
default behavior? Unfortunately, a simple rescue doesn't catch
interrupt (and other signals). I guess I could set up a signal
handler to catch it. It would be a whole lot easier if I could
just redefine the default print stacktrace method.


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around=20
http://mail.yahoo.com=20
 
P

Pit Capitain

Eric said:
I already figured out that one. Any way to override the
default behavior? Unfortunately, a simple rescue doesn't catch
interrupt (and other signals). I guess I could set up a signal
handler to catch it. It would be a whole lot easier if I could
just redefine the default print stacktrace method.

Works for me on Windows 2000. From looking at the source code, I don't
think you can change the default behaviour, sorry.

Regards,
Pit
 
D

Devin Mullins

Pit said:
Catch the exception and print its backtrace

begin
call_deeply_nested_method
rescue Exception => ex
puts ex, ex.backtrace
end

I am continually reminded of how little I know. :)

BTW, Exception is not necessary:

begin
call_deeply_nested_method
rescue => ex #defaults to StandardError
puts ex, ex.backtrace
end

Devin
 
T

tkersh

If you encounter this issue inside of a Unit Test for a controller
(functional test), it doesn't work to put the above code into any of
your test methods.

If you're using Rails-generated code, look for the line at the top of
your controller_test class that looks like this:

# Re-raise errors caught by the controller.
class FooController; def rescue_action(e) raise e end; end

and replace it with one that looks like this:

class FooController; def rescue_action(ex) puts ex, ex.backtrace end;
end

Regards,
Tad
 

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

Similar Threads

Magazine name 1
Functioning website now fails 0
Simple Q: bit string -> integer 2
specifying path 1
daemons 0
What is the meaning of Dim 6
how to run SciTE from any path 1
where does song.name come from? 3

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top