Exemplo n.º 1
0
void
push_error_context_jump(jmp_buf *jump, error_printer *printerror,
                        const char *contextstring)
{
  struct error_context *ec;

  ec = error_context_new();
  set_error_printer(ec, printerror, contextstring);
  set_jump_handler(ec, jump);
  onerr_abort = 0;
}
Exemplo n.º 2
0
void
push_error_context_func(error_handler *func, error_printer *printerror,
                        const char *contextstring)
{
  struct error_context *ec;

  ec = error_context_new();
  set_error_printer(ec, printerror, contextstring);
  set_func_handler(ec, func);
  onerr_abort = 0;
}
Exemplo n.º 3
0
void
push_error_context_jump(jmp_buf *jumper,
                        error_printer_func *printer,
                        const void *printer_data)
{
  struct error_context *ec;

  ec = error_context_new();
  set_error_printer(ec, printer, printer_data);
  set_jump_handler(ec, jumper);
  onerr_abort = 0;
}
Exemplo n.º 4
0
void
push_error_context_func(error_handler_func *handler,
                        error_printer_func *printer,
                        const void *printer_data)
{
  struct error_context *ec;

  ec = error_context_new();
  set_error_printer(ec, printer, printer_data);
  set_func_handler(ec, handler);
  onerr_abort = 0;
}
Exemplo n.º 5
0
/**
 * Unwind the current error context by running its registered cleanups.
 */
void
pop_error_context(int flagset)
{
  struct error_context *tecp;

  tecp= econtext;
  econtext= tecp->next;

  /* If we are cleaning up normally, do not print anything. */
  if (flagset & ehflag_normaltidy)
    set_error_printer(tecp, NULL, NULL);
  run_cleanups(tecp,flagset);
  free(tecp);
}
Exemplo n.º 6
0
static void
run_cleanups(struct error_context *econ, int flagsetin)
{
  static volatile int preventrecurse= 0;
  struct cleanup_entry *volatile cep;
  struct cleanup_entry *ncep;
  struct error_context recurserr, *oldecontext;
  jmp_buf recurse_jump;
  volatile int i, flagset;

  if (econ->printer.func)
    econ->printer.func(econ->errmsg, econ->printer.data);

  if (++preventrecurse > 3) {
    onerr_abort++;
    print_cleanup_error(_("too many nested errors during error recovery"), NULL);
    flagset= 0;
  } else {
    flagset= flagsetin;
  }
  cep= econ->cleanups;
  oldecontext= econtext;
  while (cep) {
    for (i=0; i<NCALLS; i++) {
      if (cep->calls[i].call && cep->calls[i].mask & flagset) {
        if (setjmp(recurse_jump)) {
          run_cleanups(&recurserr, ehflag_bombout | ehflag_recursiveerror);
        } else {
          recurserr.cleanups= NULL;
          recurserr.next= NULL;
          set_error_printer(&recurserr, print_cleanup_error, NULL);
          set_jump_handler(&recurserr, &recurse_jump);
          econtext= &recurserr;
          cep->calls[i].call(cep->argc,cep->argv);
        }
        econtext= oldecontext;
      }
    }
    flagset &= cep->cpmask;
    flagset |= cep->cpvalue;
    ncep= cep->next;
    if (cep != &emergency.ce) free(cep);
    cep= ncep;
  }
  preventrecurse--;
}