mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add rb_mod_exc_raise
function and replace duplicate code
This commit is contained in:
parent
99dad28b7c
commit
a46c220320
Notes:
git
2021-10-30 19:25:01 +09:00
Merged: https://github.com/ruby/ruby/pull/5063 Merged-By: nobu <nobu@ruby-lang.org>
1 changed files with 13 additions and 8 deletions
21
error.c
21
error.c
|
@ -3188,36 +3188,41 @@ rb_syserr_new_path_in(const char *func_name, int n, VALUE path)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NORETURN(static void rb_mod_exc_raise(VALUE exc, VALUE mod));
|
||||||
|
|
||||||
|
static void
|
||||||
|
rb_mod_exc_raise(VALUE exc, VALUE mod)
|
||||||
|
{
|
||||||
|
rb_extend_object(exc, mod);
|
||||||
|
rb_exc_raise(exc);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mod_sys_fail(VALUE mod, const char *mesg)
|
rb_mod_sys_fail(VALUE mod, const char *mesg)
|
||||||
{
|
{
|
||||||
VALUE exc = make_errno_exc(mesg);
|
VALUE exc = make_errno_exc(mesg);
|
||||||
rb_extend_object(exc, mod);
|
rb_mod_exc_raise(exc, mod);
|
||||||
rb_exc_raise(exc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
|
rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
|
||||||
{
|
{
|
||||||
VALUE exc = make_errno_exc_str(mesg);
|
VALUE exc = make_errno_exc_str(mesg);
|
||||||
rb_extend_object(exc, mod);
|
rb_mod_exc_raise(exc, mod);
|
||||||
rb_exc_raise(exc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
|
rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
|
||||||
{
|
{
|
||||||
VALUE exc = rb_syserr_new(e, mesg);
|
VALUE exc = rb_syserr_new(e, mesg);
|
||||||
rb_extend_object(exc, mod);
|
rb_mod_exc_raise(exc, mod);
|
||||||
rb_exc_raise(exc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
|
rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
|
||||||
{
|
{
|
||||||
VALUE exc = rb_syserr_new_str(e, mesg);
|
VALUE exc = rb_syserr_new_str(e, mesg);
|
||||||
rb_extend_object(exc, mod);
|
rb_mod_exc_raise(exc, mod);
|
||||||
rb_exc_raise(exc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue