save stacktrace in error objects
This commit is contained in:
parent
920524dc40
commit
5893dd5b5c
|
@ -41,6 +41,7 @@ struct pic_error {
|
|||
} type;
|
||||
struct pic_string *msg;
|
||||
pic_value irrs;
|
||||
pic_str *stack;
|
||||
};
|
||||
|
||||
#define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR)
|
||||
|
|
|
@ -65,7 +65,7 @@ pic_print_backtrace(pic_state *pic, struct pic_error *e)
|
|||
/* TODO: print error irritants */
|
||||
|
||||
trace = pic_strcat(pic, trace, pic_str_new(pic, "\n", 1));
|
||||
trace = pic_strcat(pic, trace, pic_get_backtrace(pic));
|
||||
trace = pic_strcat(pic, trace, e->stack);
|
||||
|
||||
/* print! */
|
||||
printf("%s", pic_str_cstr(trace));
|
||||
|
|
|
@ -96,6 +96,7 @@ pic_errorf(pic_state *pic, const char *fmt, ...)
|
|||
e->type = PIC_ERROR_OTHER;
|
||||
e->msg = pic_str_ptr(pic_car(pic, err_line));
|
||||
e->irrs = pic_cdr(pic, err_line);
|
||||
e->stack = pic_get_backtrace(pic);
|
||||
|
||||
pic_throw(pic, e);
|
||||
}
|
||||
|
@ -133,6 +134,7 @@ pic_error_raise(pic_state *pic)
|
|||
e->type = PIC_ERROR_RAISED;
|
||||
e->msg = pic_str_new_cstr(pic, "object is raised");
|
||||
e->irrs = pic_list1(pic, v);
|
||||
e->stack = pic_get_backtrace(pic);
|
||||
|
||||
pic_throw(pic, e);
|
||||
}
|
||||
|
@ -151,6 +153,7 @@ pic_error_error(pic_state *pic)
|
|||
e->type = PIC_ERROR_OTHER;
|
||||
e->msg = str;
|
||||
e->irrs = pic_list_by_array(pic, argc, argv);
|
||||
e->stack = pic_get_backtrace(pic);
|
||||
|
||||
pic_throw(pic, e);
|
||||
}
|
||||
|
|
1
src/gc.c
1
src/gc.c
|
@ -391,6 +391,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
|||
struct pic_error *err = (struct pic_error *)obj;
|
||||
gc_mark_object(pic,(struct pic_object *)err->msg);
|
||||
gc_mark(pic, err->irrs);
|
||||
gc_mark_object(pic, (struct pic_object *)err->stack);
|
||||
break;
|
||||
}
|
||||
case PIC_TT_STRING: {
|
||||
|
|
Loading…
Reference in New Issue