backtrace_locations -> [Thread::Backtrace::Location][permalink][rdoc][edit]-
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はありません。
例: test.rb
require "date" def check_long_month(month) return if Date.new(2000, month, -1).day == 31 raise "#{month} is not long month" end def get_exception return begin yield rescue => e e end end e = get_exception { check_long_month(2) } p e.backtrace_locations # => ["test.rb:4:in 'check_long_month'", "test.rb:15:in 'block in <main>'", "test.rb:9:in 'get_exception'", "test.rb:15:in '<main>'"][SEE_ALSO] Exception#backtrace