summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcremno <[email protected]>2014-04-16 20:44:07 +0200
committercremno <[email protected]>2014-04-16 20:44:07 +0200
commitb4bb2a700a01e80beb285f2b53966dfde0bad50d (patch)
tree9186db14c6a8192e7af9830e216485583590f904
parent93c82514dcce47f7c72d1ab24fcbecdacbd072d6 (diff)
downloadmruby-b4bb2a700a01e80beb285f2b53966dfde0bad50d.tar.gz
mruby-b4bb2a700a01e80beb285f2b53966dfde0bad50d.zip
convert exception message to string
fixes: mruby -e "p ArgumentError.new(1)"
-rw-r--r--src/error.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/error.c b/src/error.c
index feec9dbc5..87e4d6412 100644
--- a/src/error.c
+++ b/src/error.c
@@ -127,7 +127,12 @@ exc_inspect(mrb_state *mrb, mrb_value exc)
mesg = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "mesg"));
file = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "file"));
line = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "line"));
- append_mesg = !mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0;
+
+ append_mesg = !mrb_nil_p(mesg);
+ if (append_mesg) {
+ mesg = mrb_obj_as_string(mrb, mesg);
+ append_mesg = RSTRING_LEN(mesg) > 0;
+ }
if (!mrb_nil_p(file) && !mrb_nil_p(line)) {
str = mrb_str_dup(mrb, file);