1
0
Fork 0
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:
S.H 2021-10-30 19:24:41 +09:00 committed by GitHub
parent 99dad28b7c
commit a46c220320
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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>

21
error.c
View file

@ -3188,36 +3188,41 @@ rb_syserr_new_path_in(const char *func_name, int n, VALUE path)
}
#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
rb_mod_sys_fail(VALUE mod, const char *mesg)
{
VALUE exc = make_errno_exc(mesg);
rb_extend_object(exc, mod);
rb_exc_raise(exc);
rb_mod_exc_raise(exc, mod);
}
void
rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
{
VALUE exc = make_errno_exc_str(mesg);
rb_extend_object(exc, mod);
rb_exc_raise(exc);
rb_mod_exc_raise(exc, mod);
}
void
rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
{
VALUE exc = rb_syserr_new(e, mesg);
rb_extend_object(exc, mod);
rb_exc_raise(exc);
rb_mod_exc_raise(exc, mod);
}
void
rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
{
VALUE exc = rb_syserr_new_str(e, mesg);
rb_extend_object(exc, mod);
rb_exc_raise(exc);
rb_mod_exc_raise(exc, mod);
}
static void