Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force Ruby to show a full stack trace? [duplicate]

I just got this error message:

... from c:/ruby/lib/ruby/gems/1.8/gems/...  ... 10 levels... from c:/ruby/lib/ruby/gems/1.8/gems/... ... 

and the bug (of course) is hidden somewhere in ... 10 levels....

How can I force Ruby to show a full stack trace?

like image 615
Željko Filipin Avatar asked Dec 19 '08 11:12

Željko Filipin


People also ask

How do I print a full stack trace?

Using printStackTrace() method − It print the name of the exception, description and complete stack trace including the line where exception occurred. Using toString() method − It prints the name and description of the exception. Using getMessage() method − Mostly used. It prints the description of the exception.

What is backtrace in Ruby?

This blog is part of our Ruby 2.5 series. Stack trace or backtrace is a sequential representation of the stack of method calls in a program which gets printed when an exception is raised. It is often used to find out the exact location in a program from where the exception was raised.

How do I find stack trace error?

Use the console. trace() method to get the stack trace from an error. The console. trace() method outputs the stack trace and shows the call path taken to reach the point at which the method was called.

What is stack trace Ruby?

The stack trace (usually named "backtrace" in Ruby, but also referred to as "stack backtrace" and "stack traceback") is a human-readable representation of the stack at a specific moment while running your program.


1 Answers

begin   # Code that raises exception rescue StandardError => e   puts e.backtrace end 
like image 82
Željko Filipin Avatar answered Sep 18 '22 13:09

Željko Filipin