Exception: UncaughtThrowError

Inherits:
ArgumentError show all
Defined in:
vm_eval.c,
vm_eval.c

Overview

Raised when throw is called with a tag which does not have corresponding catch block.

throw "foo", "bar"

raises the exception:

UncaughtThrowError: uncaught throw "foo"

Instance Method Summary collapse

Methods inherited from Exception

#==, #backtrace, #backtrace_locations, #cause, #exception, exception, #full_message, #inspect, #message, #set_backtrace, to_tty?

Constructor Details

#initialize(*args) ⇒ Object

Raised when throw is called with a tag which does not have corresponding catch block.

throw "foo", "bar"

raises the exception:

UncaughtThrowError: uncaught throw "foo"


2056
2057
2058
2059
2060
2061
2062
2063
2064
# File 'vm_eval.c', line 2056

static VALUE
uncaught_throw_init(int argc, const VALUE *argv, VALUE exc)
{
    rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
    rb_call_super(argc - 2, argv + 2);
    rb_ivar_set(exc, id_tag, argv[0]);
    rb_ivar_set(exc, id_value, argv[1]);
    return exc;
}

Instance Method Details

#tagObject

Return the tag object which was called for.

Returns:



2073
2074
2075
2076
2077
# File 'vm_eval.c', line 2073

static VALUE
uncaught_throw_tag(VALUE exc)
{
    return rb_ivar_get(exc, id_tag);
}

#to_sString

Returns formatted message with the inspected tag.

Returns:



2099
2100
2101
2102
2103
2104
2105
# File 'vm_eval.c', line 2099

static VALUE
uncaught_throw_to_s(VALUE exc)
{
    VALUE mesg = rb_attr_get(exc, id_mesg);
    VALUE tag = uncaught_throw_tag(exc);
    return rb_str_format(1, &tag, mesg);
}

#valueObject

Return the return value which was called for.

Returns:



2086
2087
2088
2089
2090
# File 'vm_eval.c', line 2086

static VALUE
uncaught_throw_value(VALUE exc)
{
    return rb_ivar_get(exc, id_value);
}