るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rubygems/defaults ruby_engine
  5. rake ruby

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Exception#exception(error_message) -> Exception (36468.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 (36268.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

//}...

TracePoint#raised_exception -> Exception (18557.0)

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

...します。

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

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

t
race.enable
b...
...egin
0/0
rescue
end

//}...

Fiber#raise(exception, message = nil, backtrace = nil) -> object (18395.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。

その他のケースでは、最初の引数は Exception Exception
のインスタンスを返す exception メソッドを持...
...

@
param message 例外のメッセージとなる文字列です。
@
param exception 発生させる例外です。
@
param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f.resume
f.raise "Er...
...ror!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end

:exit
end


p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...

Fiber#raise -> object (18295.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。

その他のケースでは、最初の引数は Exception Exception
のインスタンスを返す exception メソッドを持...
...

@
param message 例外のメッセージとなる文字列です。
@
param exception 発生させる例外です。
@
param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f.resume
f.raise "Er...
...ror!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end

:exit
end


p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...

絞り込み条件を変える

Fiber#raise(message) -> object (18295.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。

その他のケースでは、最初の引数は Exception Exception
のインスタンスを返す exception メソッドを持...
...

@
param message 例外のメッセージとなる文字列です。
@
param exception 発生させる例外です。
@
param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f.resume
f.raise "Er...
...ror!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end

:exit
end


p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...

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

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

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

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

//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return...
...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


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] (15243.0)

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

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

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

//emlist[例][ruby]{
def methd
raise

end


begin
methd
rescue => e
p e.backtrace
end


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

@see Exception#backtrace_locations...

Exception#set_backtrace(errinfo) -> nil | String | [String] (15143.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 `<main>'"]
$!.set_ba...
...cktrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end

//}...

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

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

...列を返します。

返される文字列は Ruby が捕捉されなかった例外を標準エラー出力に出力するときと
同じ形式です。
そのため、メソッド呼び出し時に $stderr が変更されておらず、$stderr.tty? が真の場合は
エスケープシーケン...
...highlight と order は 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 recent call last):\ntest.rb:2:in `<mai...
...字装飾がついています。


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

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

絞り込み条件を変える

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

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

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

@
param other 自身と比較したいオブジェクトを指定します。...
...
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

en...
...ts = [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, message, backtrace が同一のため t...
<< 1 2 > >>