Beispiel #1
0
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
    VALUE mesg, backtrace;
    ID id_mesg;

    if (exc == obj) return Qtrue;
    CONST_ID(id_mesg, "mesg");

    if (rb_obj_class(exc) != rb_obj_class(obj)) {
	ID id_message, id_backtrace;
	CONST_ID(id_message, "message");
	CONST_ID(id_backtrace, "backtrace");

	if (rb_respond_to(obj, id_message) && rb_respond_to(obj, id_backtrace)) {
	    mesg = rb_funcall(obj, id_message, 0, 0);
	    backtrace = rb_funcall(obj, id_backtrace, 0, 0);
	}
	else {
	    return Qfalse;
	}
    }
    else {
	mesg = rb_attr_get(obj, id_mesg);
	backtrace = exc_backtrace(obj);
    }

    if (!rb_equal(rb_attr_get(exc, id_mesg), mesg))
	return Qfalse;
    if (!rb_equal(exc_backtrace(exc), backtrace))
	return Qfalse;
    return Qtrue;
}
Beispiel #2
0
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
    VALUE mesg, backtrace;

    if (exc == obj) return Qtrue;

    if (rb_obj_class(exc) != rb_obj_class(obj)) {
	int status = 0;

	obj = rb_protect(try_convert_to_exception, obj, &status);
	if (status || obj == Qundef) {
	    rb_set_errinfo(Qnil);
	    return Qfalse;
	}
	if (rb_obj_class(exc) != rb_obj_class(obj)) return Qfalse;
	mesg = rb_check_funcall(obj, id_message, 0, 0);
	if (mesg == Qundef) return Qfalse;
	backtrace = rb_check_funcall(obj, id_backtrace, 0, 0);
	if (backtrace == Qundef) return Qfalse;
    }
    else {
	mesg = rb_attr_get(obj, id_mesg);
	backtrace = exc_backtrace(obj);
    }

    if (!rb_equal(rb_attr_get(exc, id_mesg), mesg))
	return Qfalse;
    if (!rb_equal(exc_backtrace(exc), backtrace))
	return Qfalse;
    return Qtrue;
}
Beispiel #3
0
static VALUE
exc_equal(VALUE exc, SEL sel, VALUE obj)
{
    VALUE mesg, backtrace;
    if (exc == obj) {
	return Qtrue;
    }
    ID id_mesg = rb_intern("mesg");
    if (rb_obj_class(exc) != rb_obj_class(obj)) {
	SEL sel_message = sel_registerName("message");
	SEL sel_backtrace = sel_registerName("backtrace");

	mesg = rb_vm_check_call(obj, sel_message, 0, NULL);
	if (mesg == Qundef) {
	    return Qfalse;
	}
	backtrace = rb_vm_check_call(obj, sel_backtrace, 0, NULL);
	if (backtrace == Qundef) {
	    return Qfalse;
	}
    }
    else {
        mesg = rb_attr_get(obj, id_mesg);
        backtrace = exc_backtrace(obj, 0);
    }
    if (!rb_equal(rb_attr_get(exc, id_mesg), mesg)) {
        return Qfalse;
    }
    if (!rb_equal(exc_backtrace(exc, 0), backtrace)) {
        return Qfalse;
    }
    return Qtrue;
}
Beispiel #4
0
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
    ID id_mesg = rb_intern("mesg");

    if (exc == obj) return Qtrue;
    if (rb_obj_class(exc) != rb_obj_class(obj))
	return Qfalse;
    if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
	return Qfalse;
    if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
	return Qfalse;
    return Qtrue;
}