summaryrefslogtreecommitdiffhomepage
path: root/src/error.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-09-12 13:56:35 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-09-12 13:56:35 -0700
commit75002290b0807dc638ed0aaca0104c0a24c91c0a (patch)
tree13e6ac1459433e33a5ec2da5d13cd19cfc34f0a6 /src/error.c
parent3a49dfd198da706ffc5ccfc68125d8e332c1b354 (diff)
parent7a7f267b88904743278dc265fbecd46964ff1570 (diff)
downloadmruby-75002290b0807dc638ed0aaca0104c0a24c91c0a.tar.gz
mruby-75002290b0807dc638ed0aaca0104c0a24c91c0a.zip
Merge pull request #468 from iij/pr-exception-without-mesg
check if an Exception instance has a "mesg" attribute
Diffstat (limited to 'src/error.c')
-rw-r--r--src/error.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/error.c b/src/error.c
index 1adf5cb05..1f352c853 100644
--- a/src/error.c
+++ b/src/error.c
@@ -134,20 +134,23 @@ exc_inspect(mrb_state *mrb, mrb_value exc)
mrb_str_cat2(mrb, str, ":");
mrb_str_append(mrb, str, line);
mrb_str_cat2(mrb, str, ": ");
- if (RSTRING_LEN(mesg) > 0) {
+ if (!mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0) {
mrb_str_append(mrb, str, mesg);
mrb_str_cat2(mrb, str, " (");
}
mrb_str_cat2(mrb, str, mrb_obj_classname(mrb, exc));
- if (RSTRING_LEN(mesg) > 0) {
+ if (!mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0) {
mrb_str_cat2(mrb, str, ")");
}
}
else {
str = mrb_str_new2(mrb, mrb_obj_classname(mrb, exc));
- if (RSTRING_LEN(mesg) > 0) {
+ if (!mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0) {
mrb_str_cat2(mrb, str, ": ");
mrb_str_append(mrb, str, mesg);
+ } else {
+ mrb_str_cat2(mrb, str, ": ");
+ mrb_str_cat2(mrb, str, mrb_obj_classname(mrb, exc));
}
}
return str;