From: Brian Candler Date: 2008-10-21T00:23:52+09:00 Subject: Re: Error Exception if script doesn't run jackster the jackle wrote: > I would like to be able to add the line number of the file into the > error message with the file name ($0) but when I try other global > variables such as $@ or $. I don't get the line number of the script > that failed? Use __FILE__ and __LINE__ You probably don't want $0, although it will work if all your code is in one file; if your script was called foo.rb but it did "require 'bar'" and the error was in bar.rb, then __FILE__ would be bar.rb but $0 would be foo.rb But in any case, you don't need this because raise "Hell" gives you a stack backtrace anyway, the first line of which is the line where the raise occurred. begin raise "Hell" rescue Exception => e puts "Error: #{e.message} at #{e.backtrace.first}" end -- Posted via http://www.ruby-forum.com/.