From 9a51fecc55dca8f4feb0b558c048532d5f5b1f3e Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 31 Aug 2000 05:29:54 +0000 Subject: matz git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index 73a24c941..8e1c25b51 100644 --- a/object.c +++ b/object.c @@ -853,8 +853,12 @@ rb_convert_type(val, type, tname, method) arg1.val = arg2.val = val; arg1.s = method; arg2.s = tname; - val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2); - Check_Type(val, type); + val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2, + rb_eStandardError, rb_eNameError, 0); + if (TYPE(val) != type) { + rb_raise(rb_eTypeError, "%s#%s should return %s", + rb_class2name(CLASS_OF(arg1.val)), method, tname); + } return val; } @@ -888,9 +892,11 @@ rb_Integer(val) arg1.val = arg2.val = val; arg1.s = "to_i"; arg2.s = "Integer"; - val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2); + val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2, + rb_eStandardError, rb_eNameError, 0); if (!rb_obj_is_kind_of(val, rb_cInteger)) { - rb_raise(rb_eTypeError, "to_i should return Integer"); + rb_raise(rb_eTypeError, "%s#to_i should return Integer", + rb_class2name(CLASS_OF(arg1.val))); } return val; } -- cgit