Sets a routine to be called on detection of errors.


#include "petscsys.h" 
PetscErrorCode PetscPushErrorHandler(PetscErrorCode (*handler)(MPI_Comm comm, int line, const char *fun, const char *file, PetscErrorCode n, PetscErrorType p, const char *mess, void *ctx), void *ctx)

Not Collective, No Fortran Support

Input Parameters#

  • handler - error handler routine

  • ctx - optional handler context that contains information needed by the handler (for example file pointers for error messages etc.)

Calling sequence of handler#

  • comm - communicator over which error occurred

  • line - the line number of the error (usually indicated by __LINE__ in the calling routine)

  • file - the file in which the error was detected (usually indicated by __FILE__ in the calling routine)

  • fun - the function name of the calling routine

  • n - the generic error number (see list defined in include/petscerror.h)

  • p - PETSC_ERROR_INITIAL if error just detected, otherwise PETSC_ERROR_REPEAT

  • mess - an error text string, usually just printed to the screen

  • ctx - the error handler context

Options Database Keys#

  • -on_error_attach_debugger <noxterm,lldb or gdb> - starts up the debugger if an error occurs

  • -on_error_abort - aborts the program if an error occurs


The currently available PETSc error handlers include PetscTraceBackErrorHandler(), PetscAttachDebuggerErrorHandler(), PetscAbortErrorHandler(), PetscMPIAbortErrorHandler(), and PetscReturnErrorHandler().

Fortran Note#

You can only push a single error handler from Fortran before popping it.

See Also#

PetscPopErrorHandler(), PetscAttachDebuggerErrorHandler(), PetscAbortErrorHandler(), PetscTraceBackErrorHandler(), PetscPushSignalHandler(), PetscErrorType, PETSC_ERROR_INITIAL, PETSC_ERROR_REPEAT, PetscErrorCode







Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages