summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-18 01:56:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-02-18 01:56:47 +0000
commita9662810df18371af7492dd8298cc0cccc13c7c7 (patch)
tree5a1131ad0ca461f67177e1c7282eacc92356f864 /error.c
parent14aa2e8dda852b6b9277a8a7e16a78654edf1767 (diff)
1.1b8pre1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@76 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/error.c b/error.c
index 4c8aea5964..1cdf4692f0 100644
--- a/error.c
+++ b/error.c
@@ -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++;
}
@@ -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