From 18b2683b97ae54d4f2f15c19076f33aa29eaf2b7 Mon Sep 17 00:00:00 2001 From: Yukihiro Matz Matsumoto Date: Wed, 27 Mar 2013 23:41:23 +0900 Subject: use new mrb_format API from mrb_raisef; its only format specifier is "%S" (stringify) and takes mrb_value; close #1062 --- src/error.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/error.c') diff --git a/src/error.c b/src/error.c index 954140418..52e4958a1 100644 --- a/src/error.c +++ b/src/error.c @@ -281,16 +281,12 @@ void mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...) { va_list args; - char buf[256]; - int n; + mrb_value mesg; va_start(args, fmt); - n = vsnprintf(buf, sizeof(buf), fmt, args); + mesg = mrb_vformat(mrb, fmt, args); va_end(args); - if (n < 0) { - n = 0; - } - mrb_exc_raise(mrb, mrb_exc_new(mrb, c, buf, n)); + mrb_exc_raise(mrb, mrb_exc_new3(mrb, c, mesg)); } void @@ -393,7 +389,7 @@ exception_call: break; default: - mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 0..3)", argc); + mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 0..3)", mrb_fixnum_value(argc)); break; } if (argc > 0) { -- cgit v1.2.3