mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Use mrb_exc_new_str_lit widely
This commit is contained in:
+2
-2
@@ -12,6 +12,7 @@
|
||||
#include "mruby/proc.h"
|
||||
#include "mruby/string.h"
|
||||
#include "mruby/debug.h"
|
||||
#include "mruby/error.h"
|
||||
|
||||
#if !defined(_WIN32) && SIZE_MAX < UINT32_MAX
|
||||
# define SIZE_ERROR_MUL(x, y) ((x) > SIZE_MAX / (y))
|
||||
@@ -467,8 +468,7 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
|
||||
static void
|
||||
irep_error(mrb_state *mrb)
|
||||
{
|
||||
static const char msg[] = "irep load error";
|
||||
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
|
||||
mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "irep load error"));
|
||||
}
|
||||
|
||||
mrb_value
|
||||
|
||||
+3
-4
@@ -24,6 +24,7 @@
|
||||
#include "mruby.h"
|
||||
#include "mruby/compile.h"
|
||||
#include "mruby/proc.h"
|
||||
#include "mruby/error.h"
|
||||
#include "node.h"
|
||||
#include "mrb_throw.h"
|
||||
|
||||
@@ -5398,8 +5399,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
|
||||
return mrb_undef_value();
|
||||
}
|
||||
else {
|
||||
static const char msg[] = "syntax error";
|
||||
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, msg, sizeof(msg) - 1));
|
||||
mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
|
||||
mrb_parser_free(p);
|
||||
return mrb_undef_value();
|
||||
}
|
||||
@@ -5407,8 +5407,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
|
||||
proc = mrb_generate_code(mrb, p);
|
||||
mrb_parser_free(p);
|
||||
if (proc == NULL) {
|
||||
static const char msg[] = "codegen error";
|
||||
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
|
||||
mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
|
||||
return mrb_undef_value();
|
||||
}
|
||||
if (c) {
|
||||
|
||||
@@ -1209,8 +1209,7 @@ RETRY_TRY_BLOCK:
|
||||
struct REnv *e = uvenv(mrb, lv-1);
|
||||
if (!e) {
|
||||
mrb_value exc;
|
||||
static const char m[] = "super called outside of method";
|
||||
exc = mrb_exc_new(mrb, E_NOMETHOD_ERROR, m, sizeof(m) - 1);
|
||||
exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
|
||||
mrb->exc = mrb_obj_ptr(exc);
|
||||
goto L_RAISE;
|
||||
}
|
||||
@@ -1424,7 +1423,7 @@ RETRY_TRY_BLOCK:
|
||||
goto L_RAISE;
|
||||
}
|
||||
if (mrb->c->prev->ci == mrb->c->prev->cibase) {
|
||||
mrb_value exc = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, mrb_str_new_lit(mrb, "double resume"));
|
||||
mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "double resume");
|
||||
mrb->exc = mrb_obj_ptr(exc);
|
||||
goto L_RAISE;
|
||||
}
|
||||
@@ -2192,8 +2191,7 @@ RETRY_TRY_BLOCK:
|
||||
CASE(OP_TCLASS) {
|
||||
/* A B R(A) := target_class */
|
||||
if (!mrb->c->ci->target_class) {
|
||||
static const char msg[] = "no target class or module";
|
||||
mrb_value exc = mrb_exc_new(mrb, E_TYPE_ERROR, msg, sizeof(msg) - 1);
|
||||
mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR, "no target class or module");
|
||||
mrb->exc = mrb_obj_ptr(exc);
|
||||
goto L_RAISE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user