diff options
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -6,7 +6,7 @@ $Date$ created at: Mon Aug 9 16:11:34 JST 1993 - Copyright (C) 1993-1996 Yukihiro Matsumoto + Copyright (C) 1993-1998 Yukihiro Matsumoto ************************************************/ @@ -168,8 +168,19 @@ rb_check_type(x, t) if (TYPE(x)!=(t)) { while (type->type >= 0) { if (type->type == t) { + char *etype; + + if (NIL_P(x)) { + etype = "nil"; + } + else if (rb_special_const_p(x)) { + etype = RSTRING(obj_as_string(x))->ptr; + } + else { + etype = rb_class2name(CLASS_OF(x)); + } TypeError("wrong argument type %s (expected %s)", - rb_class2name(CLASS_OF(x)), type->name); + etype, type->name); } type++; } @@ -254,7 +265,7 @@ exc_inspect(exc) klass = CLASS_OF(exc); if (RSTRING(exc)->len == 0) { - return rb_class_path(klass); + return str_dup(rb_class_path(klass)); } str = str_new2("#<"); @@ -342,7 +353,7 @@ Init_Exception() rb_define_global_function("Exception", exception, -1); } -#define RAISE_ERROR(class) {\ +#define RAISE_ERROR(klass) {\ va_list args;\ char buf[BUFSIZ];\ \ @@ -350,7 +361,7 @@ Init_Exception() vsprintf(buf, fmt, args);\ va_end(args);\ \ - rb_raise(exc_new2(class, buf));\ + rb_raise(exc_new2(klass, buf));\ } void |