るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

検索結果

<< 1 2 > >>

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

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

...成し Exception#message 属性を error_message にして返します。

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

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

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

TracePoint#raised_exception -> Exception (27633.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
begin
0/0
r
e...

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

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

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

Fiber.yield が呼ばれていないかファイバーがすでに終了している場合、
FiberError が発生します。

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

その他のケースでは、最初の引数は Exception Exception
のインスタンスを返す exception メソッドを持ったオブジェクトである
必要があります。
この...
...@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f.resume
f.raise "Error!"...

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

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

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

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

//emlist[例: test.rb][ruby]{
r
equire "date"
def check_long_month(month)
r
eturn if...
...ate.new(2000, month, -1).day == 31
raise
"#{month} is not long month"
end

def get_exception
r
eturn begin
yield
r
escue => 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.r...
...b:9:in `get_exception'", "test.rb:15:in `<main>'"]
//}

@see Exception#backtrace...

Fiber#raise -> object (24353.0)

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

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

Fiber.yield が呼ばれていないかファイバーがすでに終了している場合、
FiberError が発生します。

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

その他のケースでは、最初の引数は Exception Exception
のインスタンスを返す exception メソッドを持ったオブジェクトである
必要があります。
この...
...@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f.resume
f.raise "Error!"...

絞り込み条件を変える

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

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

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

Fiber.yield が呼ばれていないかファイバーがすでに終了している場合、
FiberError が発生します。

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

その他のケースでは、最初の引数は Exception Exception
のインスタンスを返す exception メソッドを持ったオブジェクトである
必要があります。
この...
...@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f.resume
f.raise "Error!"...

Thread#report_on_exception -> bool (21369.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...stderr に報告します。

デフォルトはスレッド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thre...
...d.stop; raise }
a.report_on_exception = true
a.report_on_exception # => true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Threa...
...d:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Thread#report_on_exception=(newstate) (21369.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...stderr に報告します。

デフォルトはスレッド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thre...
...d.stop; raise }
a.report_on_exception = true
a.report_on_exception # => true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Threa...
...d:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Exception#backtrace -> [String] (21319.0)

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

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

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

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

end

begin
methd
r
escue => e
p e.backtrace
end

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

@see Exception#backtrace_locations...

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

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

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

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

//emlist[例][ruby]{
begin
begin
raise
"inner"
r
escue
raise
"outer"
end
r
escue
$!.backtrace # => ["/pat...
...h/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.set_backtrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end
//}...

絞り込み条件を変える

Exception#inspect -> String (15225.0)

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

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

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