diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-09-13 05:56:46 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-09-13 05:56:46 +0900 |
| commit | 8d97a8e069f2d30c882f9d287463de8ff6eabc0c (patch) | |
| tree | bb15a4de5fdc55d33b3554267918d36085f327ce | |
| parent | 540066c9e2cd89bd22201b18f09b5f7d7fbcd612 (diff) | |
| parent | 75002290b0807dc638ed0aaca0104c0a24c91c0a (diff) | |
| download | mruby-8d97a8e069f2d30c882f9d287463de8ff6eabc0c.tar.gz mruby-8d97a8e069f2d30c882f9d287463de8ff6eabc0c.zip | |
Merge branch 'master' of github.com:mruby/mruby
| -rw-r--r-- | src/error.c | 9 | ||||
| -rw-r--r-- | test/t/exception.rb | 3 |
2 files changed, 9 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; diff --git a/test/t/exception.rb b/test/t/exception.rb index 2ea319caa..76c165e95 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -269,3 +269,6 @@ assert('Exception 14') do a == :ok end +assert('Exception#inspect without message') do + Exception.new.inspect +end |
