xref: /petsc/src/sys/error/errabort.c (revision fe998a80077c9ee0917a39496df43fc256e1b478)
1 
2 /*
3        The default error handlers and code that allows one to change
4    error handlers.
5 */
6 #include <petscsys.h>           /*I "petscsys.h" I*/
7 
8 #undef __FUNCT__
9 #define __FUNCT__ "PetscAbortErrorHandler"
10 /*@C
11    PetscAbortErrorHandler - Error handler that calls abort on error.
12    This routine is very useful when running in the debugger, because the
13    user can look directly at the stack frames and the variables.
14 
15    Not Collective
16 
17    Input Parameters:
18 +  comm - communicator over which error occurred
19 .  line - the line number of the error (indicated by __LINE__)
20 .  func - function where error occured (indicated by __FUNCT__)
21 .  file - the file in which the error was detected (indicated by __FILE__)
22 .  mess - an error text string, usually just printed to the screen
23 .  n - the generic error number
24 .  p - specific error number
25 -  ctx - error handler context
26 
27    Options Database Keys:
28 +  -on_error_abort - Activates aborting when an error is encountered
29 -  -start_in_debugger [noxterm,dbx,xxgdb]  [-display name] - Starts all
30     processes in the debugger and uses PetscAbortErrorHandler().  By default the
31     debugger is gdb; alternatives are dbx and xxgdb.
32 
33    Level: developer
34 
35    Notes:
36    Most users need not directly employ this routine and the other error
37    handlers, but can instead use the simplified interface SETERRQ, which
38    has the calling sequence
39 $     SETERRQ(comm,number,mess)
40    or its variants, SETERRQ1(number,formatstring,arg1), SETERRQ2(), ... that
41    allow including arguments in the message.
42 
43    Notes for experienced users:
44    Use PetscPushErrorHandler() to set the desired error handler.  The
45    currently available PETSc error handlers include PetscTraceBackErrorHandler(),
46    PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler().
47 
48    Concepts: error handler^aborting
49    Concepts: aborting on error
50 
51 .seealso: PetscPushErrorHandler(), PetscTraceBackErrorHandler(),
52           PetscAttachDebuggerErrorHandler()
53 @*/
54 PetscErrorCode  PetscAbortErrorHandler(MPI_Comm comm,int line,const char *fun,const char *file,PetscErrorCode n,PetscErrorType p,const char *mess,void *ctx)
55 {
56   PetscFunctionBegin;
57   (*PetscErrorPrintf)("%s() line %d in %s %s\n",fun,line,file,mess);
58   abort();
59   PetscFunctionReturn(0);
60 }
61 
62