2012-04-07 37 views

回答

14

就拿回溯:

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

要获得唯一的行号 - 只需通过一个正则表达式解析出来回溯的。

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

相关问题