mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
use new E_EXCEPTION and E_STANDARD_ERROR; ref #5924
This commit is contained in:
@@ -72,7 +72,7 @@ mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t
|
||||
}
|
||||
|
||||
if (exc) {
|
||||
*exc = mrb_obj_is_kind_of(mrb, v, mrb->eException_class);
|
||||
*exc = mrb_obj_is_kind_of(mrb, v, E_EXCEPTION);
|
||||
}
|
||||
|
||||
s = mrb_inspect(mrb, v);
|
||||
|
||||
@@ -500,7 +500,7 @@ dbgcmd_quit(mrb_state *mrb, mrdb_state *mrdb)
|
||||
|
||||
if (mrdb->dbg->xm == DBG_QUIT) {
|
||||
struct RClass *exc;
|
||||
exc = mrb_define_class(mrb, "DebuggerExit", mrb->eException_class);
|
||||
exc = mrb_define_class(mrb, "DebuggerExit", E_EXCEPTION);
|
||||
mrb_raise(mrb, exc, "Exit mrdb");
|
||||
}
|
||||
return DBGST_PROMPT;
|
||||
|
||||
@@ -19,7 +19,7 @@ dbgcmd_run(mrb_state *mrb, mrdb_state *mrdb)
|
||||
if (dbg->xphase == DBG_PHASE_RUNNING){
|
||||
struct RClass *exc;
|
||||
puts("Start it from the beginning");
|
||||
exc = mrb_define_class(mrb, "DebuggerRestart", mrb->eException_class);
|
||||
exc = mrb_define_class(mrb, "DebuggerRestart", E_EXCEPTION);
|
||||
mrb_raise(mrb, exc, "Restart mrdb");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ mrb_mruby_dir_gem_init(mrb_state *mrb)
|
||||
mrb_define_method(mrb, d, "seek", mrb_dir_seek, MRB_ARGS_REQ(1));
|
||||
mrb_define_method(mrb, d, "tell", mrb_dir_tell, MRB_ARGS_NONE());
|
||||
|
||||
mrb_define_class(mrb, "IOError", mrb->eStandardError_class);
|
||||
mrb_define_class(mrb, "IOError", E_STANDARD_ERROR);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -296,11 +296,9 @@ mrb_sce_sys_fail(mrb_state *mrb, mrb_value cls)
|
||||
void
|
||||
mrb_mruby_errno_gem_init(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *e, *eno, *sce, *ste;
|
||||
struct RClass *e, *eno, *sce;
|
||||
|
||||
ste = mrb->eStandardError_class;
|
||||
|
||||
sce = mrb_define_class(mrb, "SystemCallError", ste);
|
||||
sce = mrb_define_class(mrb, "SystemCallError", E_STANDARD_ERROR);
|
||||
mrb_define_class_method(mrb, sce, "_sys_fail", mrb_sce_sys_fail, MRB_ARGS_REQ(1));
|
||||
mrb_define_method(mrb, sce, "errno", mrb_sce_errno, MRB_ARGS_NONE());
|
||||
mrb_define_method(mrb, sce, "initialize", mrb_sce_init_m, MRB_ARGS_ARG(1, 1));
|
||||
|
||||
@@ -72,7 +72,7 @@ f_exit_bang(mrb_state *mrb, mrb_value self)
|
||||
void
|
||||
mrb_mruby_exit_gem_init(mrb_state* mrb)
|
||||
{
|
||||
mrb_define_class_id(mrb, MRB_SYM(SystemExit), mrb->eException_class);
|
||||
mrb_define_class_id(mrb, MRB_SYM(SystemExit), E_EXCEPTION);
|
||||
mrb_define_method_id(mrb, mrb->kernel_module, MRB_SYM(exit), f_exit, MRB_ARGS_OPT(1));
|
||||
mrb_define_method_id(mrb, mrb->kernel_module, MRB_SYM_B(exit), f_exit_bang, MRB_ARGS_OPT(1));
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ mrb_mruby_fiber_gem_init(mrb_state* mrb)
|
||||
mrb_define_class_method(mrb, c, "yield", fiber_yield, MRB_ARGS_ANY());
|
||||
mrb_define_class_method(mrb, c, "current", fiber_current, MRB_ARGS_NONE());
|
||||
|
||||
mrb_define_class(mrb, "FiberError", mrb->eStandardError_class);
|
||||
mrb_define_class(mrb, "FiberError", E_STANDARD_ERROR);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -670,7 +670,7 @@ mrb_mruby_math_gem_init(mrb_state* mrb)
|
||||
struct RClass *mrb_math;
|
||||
mrb_math = mrb_define_module(mrb, "Math");
|
||||
|
||||
mrb_define_class_under_id(mrb, mrb_math, MRB_SYM(DomainError), mrb->eStandardError_class);
|
||||
mrb_define_class_under_id(mrb, mrb_math, MRB_SYM(DomainError), E_STANDARD_ERROR);
|
||||
|
||||
#ifdef M_PI
|
||||
mrb_define_const_id(mrb, mrb_math, MRB_SYM(PI), mrb_float_value(mrb, M_PI));
|
||||
|
||||
+3
-3
@@ -678,16 +678,16 @@ mrb_exc_get_id(mrb_state *mrb, mrb_sym name)
|
||||
mrb_value c = mrb_const_get(mrb, mrb_obj_value(mrb->object_class), name);
|
||||
|
||||
if (!mrb_class_p(c)) {
|
||||
mrb_raise(mrb, mrb->eException_class, "exception corrupted");
|
||||
mrb_raise(mrb, E_EXCEPTION, "exception corrupted");
|
||||
}
|
||||
exc = e = mrb_class_ptr(c);
|
||||
|
||||
while (e) {
|
||||
if (e == mrb->eException_class)
|
||||
if (e == E_EXCEPTION)
|
||||
return exc;
|
||||
e = e->super;
|
||||
}
|
||||
return mrb->eException_class;
|
||||
return E_EXCEPTION;
|
||||
}
|
||||
|
||||
MRB_API struct RClass*
|
||||
|
||||
+5
-5
@@ -208,7 +208,7 @@ mrb_exc_raise(mrb_state *mrb, mrb_value exc)
|
||||
mrb->exc = mrb_obj_ptr(exc);
|
||||
}
|
||||
else {
|
||||
if (!mrb_obj_is_kind_of(mrb, exc, mrb->eException_class)) {
|
||||
if (!mrb_obj_is_kind_of(mrb, exc, E_EXCEPTION)) {
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "exception object expected");
|
||||
}
|
||||
mrb_exc_set(mrb, exc);
|
||||
@@ -499,8 +499,8 @@ exception_call:
|
||||
break;
|
||||
}
|
||||
if (argc > 0) {
|
||||
if (!mrb_obj_is_kind_of(mrb, mesg, mrb->eException_class))
|
||||
mrb_raise(mrb, mrb->eException_class, "exception object expected");
|
||||
if (!mrb_obj_is_kind_of(mrb, mesg, E_EXCEPTION))
|
||||
mrb_raise(mrb, E_EXCEPTION, "exception object expected");
|
||||
if (argc > 2)
|
||||
set_backtrace(mrb, mesg, argv[2]);
|
||||
}
|
||||
@@ -683,8 +683,8 @@ mrb_init_exception(mrb_state *mrb)
|
||||
mrb_define_method(mrb, exception, "set_backtrace", exc_set_backtrace, MRB_ARGS_REQ(1));
|
||||
|
||||
mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
|
||||
mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */
|
||||
script_error = mrb_define_class(mrb, "ScriptError", mrb->eException_class); /* 15.2.37 */
|
||||
mrb_define_class(mrb, "RuntimeError", E_STANDARD_ERROR); /* 15.2.28 */
|
||||
script_error = mrb_define_class(mrb, "ScriptError", exception); /* 15.2.37 */
|
||||
mrb_define_class(mrb, "SyntaxError", script_error); /* 15.2.38 */
|
||||
stack_error = mrb_define_class(mrb, "SystemStackError", exception);
|
||||
mrb->stack_err = mrb_obj_ptr(mrb_exc_new_lit(mrb, stack_error, "stack level too deep"));
|
||||
|
||||
Reference in New Issue
Block a user