mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add rb_exc_exception function
`rb_exc_raise` and `rb_fatal` func have similar code(in `eval.c`). I think that better cut out and replace these code like `rb_exc_exception` function.
This commit is contained in:
parent
aceb8c0b4b
commit
89fa5b1348
Notes:
git
2021-03-27 16:39:24 +09:00
Merged: https://github.com/ruby/ruby/pull/4319 Merged-By: nobu <nobu@ruby-lang.org>
1 changed files with 13 additions and 8 deletions
21
eval.c
21
eval.c
|
@ -701,6 +701,17 @@ rb_longjmp(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause
|
|||
|
||||
static VALUE make_exception(int argc, const VALUE *argv, int isstr);
|
||||
|
||||
NORETURN(static void rb_exc_exception(VALUE mesg, int tag, VALUE cause));
|
||||
|
||||
static void
|
||||
rb_exc_exception(VALUE mesg, int tag, VALUE cause)
|
||||
{
|
||||
if (!NIL_P(mesg)) {
|
||||
mesg = make_exception(1, &mesg, FALSE);
|
||||
}
|
||||
rb_longjmp(GET_EC(), tag, mesg, cause);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Raises an exception in the current thread.
|
||||
* \param[in] mesg an Exception class or an \c Exception object.
|
||||
|
@ -711,10 +722,7 @@ static VALUE make_exception(int argc, const VALUE *argv, int isstr);
|
|||
void
|
||||
rb_exc_raise(VALUE mesg)
|
||||
{
|
||||
if (!NIL_P(mesg)) {
|
||||
mesg = make_exception(1, &mesg, FALSE);
|
||||
}
|
||||
rb_longjmp(GET_EC(), TAG_RAISE, mesg, Qundef);
|
||||
rb_exc_exception(mesg, TAG_RAISE, Qundef);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -727,10 +735,7 @@ rb_exc_raise(VALUE mesg)
|
|||
void
|
||||
rb_exc_fatal(VALUE mesg)
|
||||
{
|
||||
if (!NIL_P(mesg)) {
|
||||
mesg = make_exception(1, &mesg, FALSE);
|
||||
}
|
||||
rb_longjmp(GET_EC(), TAG_FATAL, mesg, Qnil);
|
||||
rb_exc_exception(mesg, TAG_FATAL, Qnil);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in a new issue