# \[SOLVED\] Gracefully exit a system.db.runPrepQuery or system.db.runPrepUpdate script statement

**URL:** <https://forum.inductiveautomation.com/t/solved-gracefully-exit-a-system-db-runprepquery-or-system-db-runprepupdate-script-statement/32695>\
**Category:** Ignition\
**Created:** [February 28, 2020, 2:03pm UTC](https://forum.inductiveautomation.com/t/solved-gracefully-exit-a-system-db-runprepquery-or-system-db-runprepupdate-script-statement/32695 "2020-02-28T14:03:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 28, 2020, 2:15pm UTC](https://forum.inductiveautomation.com/t/solved-gracefully-exit-a-system-db-runprepquery-or-system-db-runprepupdate-script-statement/32695/2 "2020-02-28T14:15:40Z")

</div>

Use a `try - except` code block. Catching exceptions is a standard feature of python, like pretty much any modern programming language.

[https://docs.python.org/2.7/reference/compound\_stmts.html#the-try-statement](https://docs.python.org/2.7/reference/compound_stmts.html#the-try-statement)

Note that if you specify the generic python Exception class in your except clause, you won't catch java-specific exceptions. You would need an extra except clause:

> [@Catch IOException?](http://forum.inductiveautomation.com/t/catch-ioexception/18612/3):
>
> Consider using two except blocks, as jython’s standard Exception won’t catch pure java exceptions. Like so: import java.lang.Exception try: # something something something except Exception, e: # jython exception except java.lang.Exception, e: # java exception

---

_[View the full topic](https://forum.inductiveautomation.com/t/solved-gracefully-exit-a-system-db-runprepquery-or-system-db-runprepupdate-script-statement/32695)._
