Ruby 2.3.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > UncaughtThrowErrorクラス

class UncaughtThrowError

クラスの継承リスト: UncaughtThrowError < ArgumentError < StandardError < Exception < Object < Kernel < BasicObject

要約

Kernel.#throw に指定した tag に対して一致する Kernel.#catch が存在しない場合に発生します。

throw "foo", "bar"
# => (例外発生) UncaughtThrowError: uncaught throw "foo"

目次

インスタンスメソッド
tag to_s value

インスタンスメソッド

tag -> object[permalink][rdoc]

Kernel.#throw に指定した tag を返します。

例:

def do_complicated_things
  throw :uncaught_label
end

begin
  do_complicated_things
rescue UncaughtThrowError => ex
  p ex.tag # => ":uncaught_label"
end
to_s -> String[permalink][rdoc]

self を tag を含む文字列表現にして返します。



def do_complicated_things
  throw :uncaught_label
end

begin
  do_complicated_things
rescue UncaughtThrowError => ex
  p ex.to_s # => "uncaught throw :uncaught_label"
end
value -> object[permalink][rdoc]

Kernel.#throw に指定した value を返します。



def do_complicated_things
  throw :uncaught_label, "uncaught_value"
end

begin
  do_complicated_things
rescue UncaughtThrowError => ex
  p ex.value # => "uncaught_value"
end