Entire stack trace

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
http://mail.yahoo.com

Eric Mahurin schrieb:

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

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.

···

--- Pit Capitain <pit@capitain.de> wrote:

Eric Mahurin schrieb:
> 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

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

Pit Capitain wrote:

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. :slight_smile:

BTW, Exception is not necessary:

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

Devin

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

Eric Mahurin schrieb:

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