るりまサーチ (Ruby 2.3.0)

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

別のキーワード

  1. _builtin cause
  2. exception cause
  3. cause _builtin
  4. cause exception

検索結果

Exception#cause -> Exception | nil (54331.0)

self の前の例外(self が rescue 節や ensure 節の中で発生した例外の場合、 その前に発生していた元々の例外)を返します。存在しない場合は nil を返し ます。

self の前の例外(self が rescue 節や ensure 節の中で発生した例外の場合、
その前に発生していた元々の例外)を返します。存在しない場合は nil を返し
ます。

//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
p $! # => #<RuntimeError: outer>
p $!.cause # => #<RuntimeError: inner>
end
//}