# PetscCallThrow
Checks error code, if non-zero it calls the C++ error handler which throws an exception 
## Synopsis
```
#include <petscerror.h>
void PetscCallThrow(PetscErrorCode ierr)
```
Not Collective


## Input Parameter

- ***ierr -*** nonzero error code, see the list of standard error codes in include/petscerror.h



## Notes
Requires PETSc to be configured with clanguage = c++. Throws a std::runtime_error() on error.

Once the error handler throws the exception you can use `PetscCallVoid()` which returns without
an error code (bad idea since the error is ignored) or `PetscCallAbort()` to have `MPI_Abort()`
called immediately.




## See Also
 `SETERRQ()`, `PetscCall()`, `SETERRABORT()`, `PetscCallAbort()`, `PetscTraceBackErrorHandler()`,
`PetscPushErrorHandler()`, `PetscError()`, `CHKMEMQ`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscerror.h.html#PetscCallThrow">include/petscerror.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscerror.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
