Ejemplo n.º 1
0
void
pic_print_backtrace(pic_state *pic, xFILE *file)
{
  assert(! pic_invalid_p(pic->err));

  if (! pic_error_p(pic->err)) {
    xfprintf(file, "raise: ");
    pic_fwrite(pic, pic->err, file);
  } else {
    struct pic_error *e;

    e = pic_error_ptr(pic->err);
    if (e->type != pic_intern_cstr(pic, "")) {
      pic_fwrite(pic, pic_obj_value(e->type), file);
      xfprintf(file, " ");
    }
    xfprintf(file, "error: ");
    pic_fwrite(pic, pic_obj_value(e->msg), file);
    xfprintf(file, "\n");

    /* TODO: print error irritants */

    xfputs(pic_str_cstr(pic, e->stack), file);
  }
}
Ejemplo n.º 2
0
static pic_value
pic_error_error_object_type(pic_state *pic)
{
  pic_value e;

  pic_get_args(pic, "o", &e);

  TYPE_CHECK(pic, e, error);

  return pic_obj_value(pic_error_ptr(pic, e)->type);
}
Ejemplo n.º 3
0
static pic_value
pic_error_error_object_irritants(pic_state *pic)
{
  pic_value e;

  pic_get_args(pic, "o", &e);

  TYPE_CHECK(pic, e, error);

  return pic_error_ptr(pic, e)->irrs;
}
Ejemplo n.º 4
0
const char *
pic_errmsg(pic_state *pic)
{
  pic_str *str;

  assert(! pic_undef_p(pic->err));

  if (! pic_error_p(pic->err)) {
    str = pic_format(pic, "~s", pic->err);
  } else {
    str = pic_error_ptr(pic->err)->msg;
  }

  return pic_str_cstr(str);
}
Ejemplo n.º 5
0
static pic_value
pic_error_file_error_p(pic_state *pic)
{
  pic_value v;
  struct pic_error *e;

  pic_get_args(pic, "o", &v);

  if (! pic_error_p(v)) {
    return pic_false_value();
  }

  e = pic_error_ptr(v);
  return pic_bool_value(e->type == PIC_ERROR_FILE);
}