More error backtrace

N

Nigel Gilbert

I am having trouble tracking down the point at which my program is
failing. I have a backtrace that looks like this:

/usr/local/lib/ruby/1.6/net/protocol.rb:468:in `new': wrong argument
type nil (expected String) (TypeError)
from /usr/local/lib/ruby/1.6/net/protocol.rb:468:in `connect'
from /usr/local/lib/ruby/1.6/net/protocol.rb:467:in `timeout'
from /usr/local/lib/ruby/1.6/net/protocol.rb:467:in `connect'
from /usr/local/lib/ruby/1.6/net/protocol.rb:449:in `initialize'
from /usr/local/lib/ruby/1.6/net/protocol.rb:149:in `new'
from /usr/local/lib/ruby/1.6/net/protocol.rb:149:in
`conn_socket'
from /usr/local/lib/ruby/1.6/net/http.rb:499:in `do_start'
from /usr/local/lib/ruby/1.6/net/protocol.rb:131:in `start'
... 6 levels...
from webcount.rb:556:in `each'
from webcount.rb:556:in `wayback'
from webcount.rb:703:in `dosite'
from webcount.rb:813

What I need to know are which lines of code are represented by "... 6
levels...". Is there any way of stopping ruby from abbreviating the
backtrace like this?

(I'm using ruby 1.6.8 (2002-12-24) [powerpc-darwin6.6])

Thanks

Nigel
 
G

Gennady

It is the default exception handling in Ruby. You can always embrace your
program
in

begin
...
rescure Exception => exception
p exception.message
p exception.backtrace # or present it in any other way you like
end

Gennady

----- Original Message -----
From: "Nigel Gilbert" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Wednesday, July 02, 2003 2:43 PM
Subject: More error backtrace
 
S

Simon Strandgaard

What I need to know are which lines of code are represented by "... 6
levels...". Is there any way of stopping ruby from abbreviating the
backtrace like this?

You will need to catch ALL exceptions yourself... like this:
ruby x.rb
Fatal-Error in program!
please report this bug.
EXCEPTION:
RuntimeError
MESSAGE:
hello world
BACKTRACE:
x.rb:2
begin
raise "hello world"
rescue Exception => e
puts <<MSG
Fatal-Error in program!
please report this bug.
EXCEPTION:
\t#{e.class.to_s}
MESSAGE:
\t#{e.message}
BACKTRACE:
#{e.backtrace.map{|t|"\t#{t}\n"}.join}
MSG
end
 

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,995
Messages
2,570,233
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top