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