类 UncaughtThrowError
当调用 throw 时,如果 tag 没有对应的 catch 代码块,则会抛出此异常。
throw "foo", "bar"
抛出异常
UncaughtThrowError: uncaught throw "foo"
公共类方法
new(*args) 点击切换源代码
文档类: UncaughtThrowError
当调用 throw 时,如果 tag 没有对应的 catch 代码块,则会抛出此异常。
throw "foo", "bar"
抛出异常
UncaughtThrowError: uncaught throw "foo"
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;
}
公共实例方法
tag → obj 点击切换源代码
返回被调用的 tag 对象。
static VALUE
uncaught_throw_tag(VALUE exc)
{
return rb_ivar_get(exc, id_tag);
}
to_s → string 点击切换源代码
返回格式化后的消息,包含被检查的 tag。
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);
}
value → obj 点击切换源代码
返回被调用的返回值。
static VALUE
uncaught_throw_value(VALUE exc)
{
return rb_ivar_get(exc, id_value);
}