void mrb_state::mrb_raisef(RClass *c, const char *fmt, ...) { va_list args; va_start(args, fmt); auto mesg = mrb_vformat(this, fmt, args); va_end(args); mrb_exc_raise(this, mrb_exc_new_str(c, mesg)); }
RString *mrb_format(mrb_state *mrb, const char *format, ...) { va_list ap; va_start(ap, format); auto str = mrb_vformat(mrb, format, ap); va_end(ap); return str; }
MRB_API mrb_noreturn void mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...) { va_list args; mrb_value mesg; va_start(args, fmt); mesg = mrb_vformat(mrb, fmt, args); va_end(args); mrb_exc_raise(mrb, mrb_exc_new_str(mrb, c, mesg)); }
void mrb_bug(mrb_state *mrb, const char *fmt, ...) { va_list ap; va_start(ap, fmt); auto str = mrb_vformat(mrb, fmt, ap); fputs("bug: ", stderr); mrb->sys.error_f("%s",str->m_ptr); //fwrite(RSTRING_PTR(str), RSTRING_LEN(str), 1, stderr); va_end(ap); exit(EXIT_FAILURE); }
MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, char const* fmt, ...) { mrb_value exc; va_list ap; va_start(ap, fmt); exc = mrb_funcall(mrb, mrb_obj_value(E_NOMETHOD_ERROR), "new", 3, mrb_vformat(mrb, fmt, ap), mrb_symbol_value(id), args); va_end(ap); mrb_exc_raise(mrb, exc); }
MRB_API mrb_value mrb_format(mrb_state *mrb, const char *format, ...) { va_list ap; mrb_value str; va_start(ap, format); str = mrb_vformat(mrb, format, ap); va_end(ap); return str; }
void mrb_warn(mrb_state *mrb, const char *fmt, ...) { #ifdef ENABLE_STDIO va_list ap; va_start(ap, fmt); auto str = mrb_vformat(mrb, fmt, ap); fputs("warning: ", stderr); fwrite(str->m_ptr, str->len, 1, stderr); va_end(ap); #endif }
void mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...) { mrb_value exc; mrb_value argv[2]; va_list args; va_start(args, fmt); argv[0] = mrb_vformat(mrb, fmt, args)->wrap(); va_end(args); argv[1] = mrb_symbol_value(id); exc = E_NAME_ERROR->new_instance(2, argv); mrb_exc_raise(mrb, exc); }
MRB_API void mrb_warn(mrb_state *mrb, const char *fmt, ...) { #ifndef MRB_DISABLE_STDIO va_list ap; mrb_value str; va_start(ap, fmt); str = mrb_vformat(mrb, fmt, ap); fputs("warning: ", stderr); fwrite(RSTRING_PTR(str), RSTRING_LEN(str), 1, stderr); va_end(ap); #endif }
MRB_API mrb_noreturn void mrb_bug(mrb_state *mrb, const char *fmt, ...) { #ifndef MRB_DISABLE_STDIO va_list ap; mrb_value str; va_start(ap, fmt); str = mrb_vformat(mrb, fmt, ap); fputs("bug: ", stderr); fwrite(RSTRING_PTR(str), RSTRING_LEN(str), 1, stderr); va_end(ap); #endif exit(EXIT_FAILURE); }
MRB_API mrb_noreturn void mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...) { mrb_value exc; mrb_value argv[2]; va_list args; va_start(args, fmt); argv[0] = mrb_vformat(mrb, fmt, args); va_end(args); argv[1] = mrb_symbol_value(id); exc = mrb_obj_new(mrb, E_NAME_ERROR, 2, argv); mrb_exc_raise(mrb, exc); }