るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

検索結果

<< 1 2 3 > >>

Hash#except(*keys) -> Hash (26114.0)

引数で指定された以外のキーとその値だけを含む Hash を返します。

...引数で指定された以外のキーとその値だけを含む Hash を返します。

引数に指定されていて Hash に存在しないキーは無視されます。

//emlist[][ruby]{
h = { a: 100, b: 200, c: 300 }
h.except(:a) # => {:b=>200, :c=>300}
//}

@see Hash#slice, ENV.except...

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

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

...elf を返します。引数を指定した場合 自身のコピー
を生成し 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 (17101.0)

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

...elf を返します。引数を指定した場合 自身のコピー
を生成し 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 (14201.0)

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

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

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

Thread#abort_on_exception -> bool (14101.0)

真の場合、そのスレッドが例外によって終了した時に、インタプリタ 全体を中断させます。false の場合、あるスレッドで起こった例 外は、Thread#join などで検出されない限りそのスレッ ドだけをなにも警告を出さずに終了させます。

...。c:Thread#exceptionを参照してください。

@param newstate 自身を実行中に例外発生した場合、インタプリタ全体を終了させるかどうかを true か false で指定します。

//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.abort_on_exception # => fal...
...se
thread.abort_on_exception = true
thread.abort_on_exception # => true
//}...

絞り込み条件を変える

Thread#abort_on_exception=(newstate) (14101.0)

真の場合、そのスレッドが例外によって終了した時に、インタプリタ 全体を中断させます。false の場合、あるスレッドで起こった例 外は、Thread#join などで検出されない限りそのスレッ ドだけをなにも警告を出さずに終了させます。

...。c:Thread#exceptionを参照してください。

@param newstate 自身を実行中に例外発生した場合、インタプリタ全体を終了させるかどうかを true か false で指定します。

//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.abort_on_exception # => fal...
...se
thread.abort_on_exception = true
thread.abort_on_exception # => true
//}...

Thread#report_on_exception -> bool (14101.0)

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

...ad.report_on_exception です。

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

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception # => tr...
...(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:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<T...
...hread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Thread#report_on_exception=(newstate) (14101.0)

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

...ad.report_on_exception です。

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

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception # => tr...
...(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:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<T...
...hread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Exception#cause -> Exception | nil (11101.0)

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

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

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

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

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

...トを指定した場合は
Except
ion#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#backtrace -> [String] (11001.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...
<< 1 2 3 > >>