Ruby 3.3 リファレンスマニュアル

class UncaughtThrowError

[edit]

要約

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

throw "foo", "bar"
# ~> UncaughtThrowError: uncaught throw "foo"

目次

インスタンスメソッド

継承しているメソッド

Exceptionから継承している特異メソッド
Exceptionから継承しているメソッド

インスタンスメソッド

tag -> objectRuby 2.2.0 から[permalink][rdoc][edit]

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 -> StringRuby 2.2.0 から[permalink][rdoc][edit]

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 -> objectRuby 2.2.0 から[permalink][rdoc][edit]

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