2014-08-25 00:38:09 -04:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "picrin.h"
|
2017-03-28 10:09:40 -04:00
|
|
|
#include "object.h"
|
|
|
|
#include "state.h"
|
2014-08-25 00:38:09 -04:00
|
|
|
|
2016-02-22 14:37:58 -05:00
|
|
|
#if PIC_USE_WRITE
|
|
|
|
|
2014-08-25 00:38:09 -04:00
|
|
|
void
|
2016-06-19 15:49:01 -04:00
|
|
|
pic_print_error(pic_state *pic, pic_value port, pic_value err)
|
2014-08-25 00:38:09 -04:00
|
|
|
{
|
2016-02-20 10:30:40 -05:00
|
|
|
if (! pic_error_p(pic, err)) {
|
2016-02-23 00:15:42 -05:00
|
|
|
pic_fprintf(pic, port, "raise: ~s", err);
|
2014-09-16 11:28:55 -04:00
|
|
|
} else {
|
2016-02-21 06:32:00 -05:00
|
|
|
struct error *e;
|
2015-06-19 13:34:00 -04:00
|
|
|
pic_value elem, it;
|
2014-08-25 00:38:09 -04:00
|
|
|
|
2017-04-06 09:29:02 -04:00
|
|
|
e = error_ptr(pic, err);
|
2017-03-28 19:32:28 -04:00
|
|
|
if (! pic_eq_p(pic, obj_value(pic, e->type), pic_intern_lit(pic, ""))) {
|
|
|
|
pic_fprintf(pic, port, "~s-", obj_value(pic, e->type));
|
2014-09-16 11:28:55 -04:00
|
|
|
}
|
2017-03-28 19:32:28 -04:00
|
|
|
pic_fprintf(pic, port, "error: ~s", obj_value(pic, e->msg));
|
2014-08-25 00:38:09 -04:00
|
|
|
|
2015-06-19 13:34:00 -04:00
|
|
|
pic_for_each (elem, e->irrs, it) { /* print error irritants */
|
2016-02-22 14:24:42 -05:00
|
|
|
pic_fprintf(pic, port, " ~s", elem);
|
2015-06-19 13:34:00 -04:00
|
|
|
}
|
2017-04-09 02:05:59 -04:00
|
|
|
pic_fprintf(pic, port, "\n");
|
2014-09-16 11:28:55 -04:00
|
|
|
}
|
2014-08-25 00:38:09 -04:00
|
|
|
}
|
2016-02-22 14:37:58 -05:00
|
|
|
|
|
|
|
#endif
|