aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-11 08:03:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-11 08:03:43 +0000
commitf24fe0566fde8bca3e2cc3d72419d987ef2e3f69 (patch)
tree8f716d6df2b6a4e00349b9c4d7958a94d02cc3b1 /error.c
parentcbb8a1166d379c8b609770810adbd4afcb451632 (diff)
downloadruby-f24fe0566fde8bca3e2cc3d72419d987ef2e3f69.tar.gz
eval_error.c: fix loop on exception in message
* error.c (rb_get_message): accessor to the message. * eval_error.c (rb_ec_error_print): handle exceptions on fetching the message. [Bug #14566] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/error.c b/error.c
index ba6f1ea689..c8b9404c63 100644
--- a/error.c
+++ b/error.c
@@ -980,7 +980,16 @@ exc_to_s(VALUE exc)
}
/* FIXME: Include eval_error.c */
-void rb_error_write(VALUE errinfo, VALUE errat, VALUE str, VALUE highlight, VALUE reverse);
+void rb_error_write(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE highlight, VALUE reverse);
+
+VALUE
+rb_get_message(VALUE exc)
+{
+ VALUE e = rb_check_funcall(exc, id_message, 0, 0);
+ if (e == Qundef) return Qnil;
+ if (!RB_TYPE_P(e, T_STRING)) e = rb_check_string_type(e);
+ return e;
+}
/*
* call-seq:
@@ -1015,7 +1024,7 @@ exc_s_to_tty_p(VALUE self)
static VALUE
exc_full_message(int argc, VALUE *argv, VALUE exc)
{
- VALUE opt, str, errat;
+ VALUE opt, str, emesg, errat;
enum {kw_highlight, kw_order, kw_max_};
static ID kw[kw_max_];
VALUE args[kw_max_] = {Qnil, Qnil};
@@ -1051,8 +1060,9 @@ exc_full_message(int argc, VALUE *argv, VALUE exc)
}
str = rb_str_new2("");
errat = rb_get_backtrace(exc);
+ emesg = rb_get_message(exc);
- rb_error_write(exc, errat, str, args[kw_highlight], args[kw_order]);
+ rb_error_write(exc, emesg, errat, str, args[kw_highlight], args[kw_order]);
return str;
}