summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'error.c')
-rw-r--r--error.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/error.c b/error.c
index bec8febff0..44ca067472 100644
--- a/error.c
+++ b/error.c
@@ -274,10 +274,7 @@ exc_initialize(argc, argv, exc)
{
VALUE mesg;
- if (rb_scan_args(argc, argv, "01", &mesg) == 0) {
- mesg = rb_str_new(0, 0);
- }
- else {
+ if (rb_scan_args(argc, argv, "01", &mesg) == 1) {
STR2CSTR(mesg); /* ensure mesg can be converted to String */
}
rb_iv_set(exc, "mesg", mesg);
@@ -308,7 +305,10 @@ static VALUE
exc_to_s(exc)
VALUE exc;
{
- return rb_iv_get(exc, "mesg");
+ VALUE mesg = rb_iv_get(exc, "mesg");
+
+ if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc));
+ return mesg;
}
static VALUE