るりまサーチ

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

別のキーワード

  1. _builtin begin
  2. range begin
  3. matchdata begin
  4. arithmeticsequence begin
  5. begin _builtin

ライブラリ

検索結果

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

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

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

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

//emlist[例: test.rb][ruby]{
r
equire "date"
def check_long_month(month)
r
eturn if...
...1
r
aise "#{month} is not long month"
end

def get_exception
r
eturn begin
yield
r
escue => 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] (6114.0)

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

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

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

//emlist[例][ruby]{
def methd
r
aise
end

begin

methd
r
escue => e
p e.backtrace
end

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

@see Exception#backtrace_locations...