# SNESSetErrorIfNotConverged
Causes `SNESSolve()` to generate an error if the solver has not converged. 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetErrorIfNotConverged(SNES snes, PetscBool flg)
```
Logically Collective


## Input Parameters

- ***snes -*** iterative context obtained from `SNESCreate()`
- ***flg -*** `PETSC_TRUE` indicates you want the error generated



## Options database keys

- ***-snes_error_if_not_converged <true,false> -*** cause an immediate error condition and stop the program if the solver does not converge





## Note
Normally PETSc continues if a solver fails to converge, you can call `SNESGetConvergedReason()` after a `SNESSolve()`
to determine if it has converged. Otherwise the solution may be inaccurate or wrong


## See Also
 `SNES`, `SNESGetErrorIfNotConverged()`, `KSPGetErrorIfNotConverged()`, `KSPSetErrorIfNotConverged()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/interface/snes.c.html#SNESSetErrorIfNotConverged">src/snes/interface/snes.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/snes/interface/snes.c)


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