るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.155秒)
トップページ > ライブラリ:ビルトイン[x] > クエリ:_builtin[x] > クエリ:I[x] > クエリ:Exception[x] > クエリ:exception[x] > クエリ:backtrace_locations[x]

別のキーワード

  1. _builtin exception
  2. exception exception
  3. _builtin abort_on_exception=
  4. _builtin abort_on_exception
  5. bigdecimal exception_overflow

クラス

検索結果

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

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

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

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

//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if...
...aise "#{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:i...
...n `<main>'"]
//}

@see Exception#backtrace...

Exception#backtrace -> [String] (41120.0)

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

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

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

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

begin
methd
rescue => e
p e.backtrace
end

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

@see Exception#backtrace_locations...