diff --git a/error.c b/error.c index 82f7f968..468935c3 100644 --- a/error.c +++ b/error.c @@ -71,8 +71,8 @@ pic_pop_try(pic_state *pic) pic->jmp = try_jmp->prev_jmp; } -static struct pic_error * -make_error(pic_state *pic, pic_sym type, pic_str *msg, pic_value irrs) +struct pic_error * +pic_make_error(pic_state *pic, pic_sym type, const char *msg, pic_value irrs) { struct pic_error *e; pic_str *stack; @@ -81,7 +81,7 @@ make_error(pic_state *pic, pic_sym type, pic_str *msg, pic_value irrs) e = (struct pic_error *)pic_obj_alloc(pic, sizeof(struct pic_error), PIC_TT_ERROR); e->type = type; - e->msg = msg; + e->msg = pic_make_str_cstr(pic, msg); e->irrs = irrs; e->stack = stack; @@ -109,7 +109,7 @@ pic_throw(pic_state *pic, pic_sym type, const char *msg, pic_value irrs) { struct pic_error *e; - e = make_error(pic, type, pic_make_str_cstr(pic, msg), irrs); + e = pic_make_error(pic, type, msg, irrs); pic_raise(pic, pic_obj_value(e)); } diff --git a/include/picrin/error.h b/include/picrin/error.h index f61f8082..1b96f3ee 100644 --- a/include/picrin/error.h +++ b/include/picrin/error.h @@ -49,6 +49,8 @@ struct pic_error { #define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR) #define pic_error_ptr(v) ((struct pic_error *)pic_ptr(v)) +struct pic_error *pic_make_error(pic_state *, pic_sym, const char *, pic_list); + #if defined(__cplusplus) } #endif