diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-10-22 22:20:24 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-10-22 22:20:24 -0700 |
| commit | f5b6f03c9e802702c6f5f74bc3e778f3c4d8baca (patch) | |
| tree | 9cdcf378589e4b3f55ce68f1e4fd15b9c63be7e7 /src/error.c | |
| parent | 18fbe4d0b74aa6e787b908a5509f834c7a1d6a18 (diff) | |
| parent | 6069a33089916d7059c2bd2aeddc02a3eb440520 (diff) | |
| download | mruby-f5b6f03c9e802702c6f5f74bc3e778f3c4d8baca.tar.gz mruby-f5b6f03c9e802702c6f5f74bc3e778f3c4d8baca.zip | |
Merge pull request #505 from monaka/pr-add-unformat-mrb_raise
Change C API for raise.
Diffstat (limited to 'src/error.c')
| -rw-r--r-- | src/error.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/error.c b/src/error.c index 5570d35f9..858c70820 100644 --- a/src/error.c +++ b/src/error.c @@ -217,7 +217,15 @@ mrb_exc_raise(mrb_state *mrb, mrb_value exc) } void -mrb_raise(mrb_state *mrb, struct RClass *c, const char *fmt, ...) +mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg) +{ + mrb_value mesg; + mesg = mrb_str_new2(mrb, msg); + mrb_exc_raise(mrb, mrb_exc_new3(mrb, c, mesg)); +} + +void +mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...) { va_list args; char buf[256]; @@ -369,7 +377,7 @@ exception_call: break; default: - mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 0..3)", argc); + mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 0..3)", argc); break; } if (argc > 0) { @@ -391,7 +399,7 @@ mrb_make_exception(mrb_state *mrb, int argc, mrb_value *argv) void mrb_sys_fail(mrb_state *mrb, const char *mesg) { - mrb_raise(mrb, E_RUNTIME_ERROR, "%s", mesg); + mrb_raise(mrb, E_RUNTIME_ERROR, mesg); } void |
