るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.014秒)
トップページ > クラス:Exception[x] > バージョン:2.1.0[x] > クエリ:backtrace[x]

別のキーワード

  1. _builtin backtrace_locations
  2. _builtin backtrace
  3. thread backtrace_locations
  4. thread backtrace
  5. exception backtrace

ライブラリ

キーワード

検索結果

Exception#backtrace -> [String] (54343.0)

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

...)
* "#{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...

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

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

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

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

//emlist[例: test.rb][ruby]{
require...
...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#backtr...

Exception#set_backtrace(errinfo) -> nil | String | [String] (18361.0)

バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。

バックトレース情報に errinfo を設定し、設定されたバックトレース
情報を返します。

@param errinfo nil、String あるいは String の配列のいずれかを指定します。

//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
$!.backtrace # => ["/path/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.se...

Exception#==(other) -> bool (88.0)

自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。

...トを指定した場合は
Exception
#exception を実行して変換を試みます。

//emlist[例][ruby]{
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

results = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results.map { |e| e.class }
# => [RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]

# class, mess...