るりまサーチ

最速Rubyリファレンスマニュアル検索!
1046件ヒット [1-100件を表示] (0.321秒)
トップページ > クエリ:-[x] > クエリ:E[x] > クエリ:I[x] > クエリ:exception[x]

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. open3 capture2e
  4. matrix det_e
  5. matrix rank_e

検索結果

<< 1 2 3 ... > >>

Exception.exception(error_message = nil) -> Exception (45775.0)

例外オブジェクトを生成して返します。

...@param error_message エラーメッセージを表す文字列を指定します。このメッセージは
属性 Exception#message の値になり、デフォルトの例外ハンドラで表示されます。

//emlist[例][ruby]{
e
= Exception.new("some message")
p e...
...# => #<Exception: some message>
p e.message # => "some message"
//}

//emlist[例][ruby]{
e
= Exception.exception("some message")
p e # => #<Exception: some message>
p e.message # => "some message"
//}...

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

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

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

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

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

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

Exception#exception -> self (45443.0)

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

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

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

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

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

DRb::DRbUnknown#exception -> DRb::DRbUnknownError (30401.0)

マーシャリングされたオブジェクトが元のオブジェクトに変換できなかった、 ということを意味する例外オブジェクトを返します。

...マーシャリングされたオブジェクトが元のオブジェクトに変換できなかった、
ということを意味する例外オブジェクトを返します。

この例外オブジェクトの DRb::DRbUnknownError#unknown を
呼び出すと、 self が返されます。...

Exception2MessageMapper#def_exception(exception_name, message_format, superclass = StandardError) -> Class (27624.0)

exception_name という名前の例外クラスを定義します。

...
exception
_name という名前の例外クラスを定義します。

@param exception_name 定義する例外クラスの名前をシンボルで指定します。

@param message_format メッセージのフォーマット。

@param superclass 定義する例外のスーパークラスを指定...
...します。
省略すると StandardError を使用します。...

絞り込み条件を変える

Exception2MessageMapper.def_exception(klass, exception_name, message_format, superklass = StandardError) -> Class (27624.0)

exception_name という名前の例外クラスを定義します。

...
exception
_name という名前の例外クラスを定義します。

@param klass 一階層上となるクラス名を指定します。

@param exception_name 例外クラスの名前をシンボルで指定します。

@param message_format メッセージのフォーマットを指定しま...
...
Kernel.#sprintf のフォーマット文字列と同じ形式を使用できます。

@param superklass 定義する例外クラスのスーパークラスを指定します。
省略すると StandardError を使用します。

@return 定義した例外...

Exception.new(error_message = nil) -> Exception (27475.0)

例外オブジェクトを生成して返します。

...@param error_message エラーメッセージを表す文字列を指定します。このメッセージは
属性 Exception#message の値になり、デフォルトの例外ハンドラで表示されます。

//emlist[例][ruby]{
e
= Exception.new("some message")
p e...
...# => #<Exception: some message>
p e.message # => "some message"
//}

//emlist[例][ruby]{
e
= Exception.exception("some message")
p e # => #<Exception: some message>
p e.message # => "some message"
//}...

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

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

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

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

//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if...
...Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
e
nd

def get_exception
return begin
yield
rescue => e
e

e
nd
e
nd

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...

Thread#report_on_exception -> bool (21550.0)

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

...tderr に報告します。

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

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

//emlist[例][ruby]{
a = Thread.new{ Threa...
...op; 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
# #<Thread:0x...
...00007fc3f48c7908@(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 -> bool (21550.0)

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

...err に報告します。

デフォルトは false です。

Thread.new { 1.times { raise } }

は $stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <mai...
...n>'
1: from -e:1:in `times'

これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:

* 例外が意図し...
...で rescue して、
その例外でスレッドが終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレ...
...derr に報告します。

デフォルトは true です。

Thread.new { 1.times { raise } }

は $stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <mai...

絞り込み条件を変える

TracePoint#raised_exception -> Exception (21508.0)

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

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

//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
e
nd
trace.enable
begin
0/0
rescue...
...
e
nd
//}...
<< 1 2 3 ... > >>