Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mruby/mruby
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Sep 12, 2012
2 parents 540066c + 7500229 commit 8d97a8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/error.c
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions test/t/exception.rb
Expand Up @@ -269,3 +269,6 @@ def exception_test14
a == :ok
end

assert('Exception#inspect without message') do
Exception.new.inspect
end

0 comments on commit 8d97a8e

Please sign in to comment.