# PetscPushErrorHandler

Sets a routine to be called on detection of errors.

### Synopsis

    #include "petsc.h"
    int PetscPushErrorHandler(int (*handler)(int,const char *,const char*,const char*,int,int,const char*,void*),void *ctx)

Not Collective

### 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

       int handler(int line,char *func,char *file,char *dir,int n,int p,char *mess,void *ctx);

| func | - the function where the error occured (indicated by __FUNCT__)
| line | - the line number of the error (indicated by __LINE__)
| file | - the file in which the error was detected (indicated by __FILE__)
| dir | - the directory of the file (indicated by __SDIR__)
| n | - the generic error number (see list defined in include/petscerror.h)
| p | - the specific error number
| mess | - an error text string, usually just printed to the screen
| ctx | - the error handler context

### Options Database Keys

| -on_error_attach_debugger <noxterm,gdb or dbx> | - - -on_error_abort

### See Also

PetscPopErrorHandler(), PetscAttachDebuggerErrorHandler(), PetscAbortErrorHandler(), PetscTraceBackErrorHandler()

Level:intermediate
Location: src/sys/src/error/err.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/examples/tutorials/ex10.c.html
src/ksp/examples/tutorials/ex27.c.html