Skip to content

Commit

Permalink
Add rb_mod_exc_raise function and replace duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
S-H-GAMELINKS committed Oct 30, 2021
1 parent 99dad28 commit a46c220
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions error.c
Expand Up @@ -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
Expand Down

0 comments on commit a46c220

Please sign in to comment.