summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2021-10-30 19:24:41 +0900
committerGitHub <noreply@github.com>2021-10-30 19:24:41 +0900
commita46c220320778c29612b80ebf2fee28a81eaa380 (patch)
tree09516cb0d0282d03203c5e4bcb3939a3f2762cd1 /error.c
parent99dad28b7c14fce45653a3573172389cb0424341 (diff)
downloadruby-a46c220320778c29612b80ebf2fee28a81eaa380.tar.gz
Add `rb_mod_exc_raise` function and replace duplicate code
Diffstat (limited to 'error.c')
-rw-r--r--error.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/error.c b/error.c
index 65bf1721a2..f9433ebe50 100644
--- a/error.c
+++ b/error.c
@@ -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