diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-20 13:56:34 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-20 13:56:34 +0000 |
| commit | caf54157ec139232d74865890ee5ae7d3ce6dd5f (patch) | |
| tree | 5fd17e6c7e642047f4acae3c95d616ba7f217118 | |
| parent | f1f12658ee64d443e17cd7e39e12556123580817 (diff) | |
* object.c (rb_convert_type, rb_to_integer)
(rb_check_convert_type): Improve error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | object.c | 15 |
2 files changed, 14 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Fri Mar 20 22:55:00 2009 Akinori MUSHA <knu@iDaemons.org> + + * object.c (rb_convert_type, rb_to_integer) + (rb_check_convert_type): Improve error messages. + Fri Mar 20 18:41:53 2009 Akinori MUSHA <knu@iDaemons.org> * array.c (Array#try_convert): New method backported from 1.9. @@ -2242,8 +2242,9 @@ rb_convert_type(val, type, tname, method) if (TYPE(val) == type) return val; v = convert_type(val, tname, method, Qtrue); if (TYPE(v) != type) { - rb_raise(rb_eTypeError, "%s#%s should return %s", - rb_obj_classname(val), method, tname); + const char *cname = rb_obj_classname(val); + rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)", + cname, tname, cname, method, rb_obj_classname(v)); } return v; } @@ -2261,8 +2262,9 @@ rb_check_convert_type(val, type, tname, method) v = convert_type(val, tname, method, Qfalse); if (NIL_P(v)) return Qnil; if (TYPE(v) != type) { - rb_raise(rb_eTypeError, "%s#%s should return %s", - rb_obj_classname(val), method, tname); + const char *cname = rb_obj_classname(val); + rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)", + cname, tname, cname, method, rb_obj_classname(v)); } return v; } @@ -2275,8 +2277,9 @@ rb_to_integer(val, method) { VALUE v = convert_type(val, "Integer", method, Qtrue); if (!rb_obj_is_kind_of(v, rb_cInteger)) { - rb_raise(rb_eTypeError, "%s#%s should return Integer", - rb_obj_classname(val), method); + const char *cname = rb_obj_classname(val); + rb_raise(rb_eTypeError, "can't convert %s to Integer (%s#%s gives %s)", + cname, cname, method, rb_obj_classname(v)); } return v; } |
