2012-04-07 49 views

回答

14

就拿回溯:

begin 
    . . . 
    # error occurs here 
    . . . 
rescue => error 
    puts "Error: " + error.message 
    puts error.backtrace 
end 

要獲得唯一的行號 - 只需通過一個正則表達式解析出來回溯的。

更多信息可以在這裏找到:Catching line numbers in ruby exceptions