るりまサーチ

最速Rubyリファレンスマニュアル検索!
374件ヒット [1-100件を表示] (0.080秒)

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. _builtin $-p
  5. _builtin p

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Exception#exception(error_message) -> Exception (36445.0)

引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。

...引数を指定した場合 自身のコピー
を生成し Exception#message 属性を error_message にして返します。

Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。

@param error_message エラーメッセージを表す文字...
...列を指定します。

//emlist[例][ruby]{
begin
# ... # 何か処理
rescue => e
raise
e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
end
//}...

Exception#exception -> self (36245.0)

引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。

...引数を指定した場合 自身のコピー
を生成し Exception#message 属性を error_message にして返します。

Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。

@param error_message エラーメッセージを表す文字...
...列を指定します。

//emlist[例][ruby]{
begin
# ... # 何か処理
rescue => e
raise
e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
end
//}...

Exception#inspect -> String (27126.0)

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

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

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

Exception#cause -> Exception | nil (24227.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#backtrace_locations -> [Thread::Backtrace::Location] (24060.0)

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

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

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

//emlist[例: test.rb][ruby]{
require...
...y == 31
raise
"#{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'", "t...
...est.rb:15:in `<main>'"]
//}

@see Exception#backtrace...

絞り込み条件を変える

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

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

...そうでない場合に false を返します。

@param other 自身と比較したいオブジェクトを指定します。
自身と異なるクラスのオブジェクトを指定した場合は
Exception
#exception を実行して変換を試みます。

//emlist[例...
...).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.m...
...is not long month", "2 is not long month", "4 is not long month"]

# class, message, backtrace が同一のため true になる
p
results[0] == results[1] # => true

# class, backtrace が同一だが、message がことなるため false になる
p
results[0] == results[2] # => false
//}...

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

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

...は 2.5.1 で追加されました。

@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で指定する必要があ...
...の一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tty? が真なら :bottom で偽なら :top です。

//emlist[例][ruby]{
begin
raise
"test"
rescue => e
p
e.full_message # => "\e[1mTraceback \e[m(most re...
...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"
end
//}

@see Exception.to_tty?...
...文字装飾がついています。


@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で指定する必要があ...

Exception#backtrace -> [String] (24020.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#set_backtrace(errinfo) -> nil | String | [String] (24014.0)

バックトレース情報に 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 `<ma...

TracePoint#raised_exception -> Exception (18528.0)

発生した例外を返します。

...生した例外を返します。

@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。

//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by...

絞り込み条件を変える

<< 1 2 3 ... > >>