るりまサーチ

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

別のキーワード

  1. _builtin runtimeerror
  2. raise runtimeerror
  3. fail runtimeerror
  4. open runtimeerror
  5. enable runtimeerror

ライブラリ

キーワード

検索結果

Exception#==(other) -> bool (19.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...

Exception#cause -> Exception | nil (13.0)

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

...その前に発生していた元々の例外)を返します。存在しない場合は nil を返し
ます。

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

Exception#full_message(highlight: true, order: :bottom) -> String (7.0)

例外の整形された文字列を返します。

...値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で指定する必要があります。
バックトレースの一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tt...
...e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
$stderr = $stdout
p e.full_message # => "test.rb:2:in `<main>': test (RuntimeError)\n"
$stderr = STDERR
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m...

Exception#inspect -> String (7.0)

self のクラス名と message を文字列にして返します。

...self のクラス名と message を文字列にして返します。

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