るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.127秒)
トップページ > クエリ:t[x] > クエリ:ruby[x] > クラス:Exception[x] > 種類:インスタンスメソッド[x] > クエリ:exception[x] > クエリ:backtrace_locations[x]

別のキーワード

  1. _builtin exception
  2. exception exception
  3. thread abort_on_exception=
  4. thread abort_on_exception
  5. _builtin abort_on_exception

ライブラリ

検索結果

Exception#backtrace_locations -> [Thread::Backtrace::Location] (36361.0)

バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。

...Exception#backtraceに似ていますが、
T
hread::Backtrace::Location の配列を返す点が異なります。

現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。

//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return...
...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 Exception#backtrace...

Exception#backtrace -> [String] (15220.0)

バックトレース情報を返します。

...line}:in `#{method}'"
(メソッド内の場合)
* "#{sourcefile}:#{sourceline}"
(トップレベルの場合)

という形式の String の配列です。

//emlist[例][ruby]{
def methd
raise
end

begin
methd
rescue => e
p e.backtrace
end

#=> ["filename.rb:2:in `methd'", "filenam...
...e.rb:6"]
//}

@see Exception#backtrace_locations...