diff options
| author | Yukihiro Matz Matsumoto <[email protected]> | 2013-03-27 23:41:23 +0900 |
|---|---|---|
| committer | Yukihiro Matz Matsumoto <[email protected]> | 2013-03-27 23:41:23 +0900 |
| commit | 18b2683b97ae54d4f2f15c19076f33aa29eaf2b7 (patch) | |
| tree | f6afd41abfd7b0ad8b76bb5e618e6ee0fbdc6723 /src/error.c | |
| parent | 8ce842a5d978132c5733cacb7c15bb3d0f5ce66d (diff) | |
| download | mruby-18b2683b97ae54d4f2f15c19076f33aa29eaf2b7.tar.gz mruby-18b2683b97ae54d4f2f15c19076f33aa29eaf2b7.zip | |
use new mrb_format API from mrb_raisef; its only format specifier is "%S" (stringify) and takes mrb_value; close #1062
Diffstat (limited to 'src/error.c')
| -rw-r--r-- | src/error.c | 12 |
1 files changed, 4 insertions, 8 deletions
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) { |
