# Try:Except: Not working

**URL:** <https://forum.inductiveautomation.com/t/try-not-working/30572>\
**Category:** Ignition\
**Created:** [December 10, 2019, 1:47pm UTC](https://forum.inductiveautomation.com/t/try-not-working/30572 "2019-12-10T13:47:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 10, 2019, 1:47pm UTC](https://forum.inductiveautomation.com/t/try-not-working/30572/1 "2019-12-10T13:47:00Z")

</div>

I have a function that has some nested functions inside. The script is called on a barcode scan event. I had to add a custom property called scanBool that sets to 1, then reverts to 0 upon completion. This is so that the code will run completely before allowing another scan input. The outside function is wrapped with a try: except: so that if the function errors out, the scanBool will reset to 0 as to not lock the scanner from further input. I’ve noticed that if one of the nested functions returns an error, the except block is not being used. Do I need to put a try except around every function? Is there a better way to handle this?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 10, 2019, 2:02pm UTC](https://forum.inductiveautomation.com/t/try-not-working/30572/2 "2019-12-10T14:02:54Z")

</div>

Putting the try except around each function call is working. Not sure if that is the best practice, but it works

---

<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:** [December 10, 2019, 2:36pm UTC](https://forum.inductiveautomation.com/t/try-not-working/30572/3 "2019-12-10T14:36:25Z")

</div>

Shouldn't be necessary. But consider using a `finally` clause instead of `except` for cleanup operations. Also, python won't catch pure java exceptions unless you use double except clauses, like so:

> [@Catch IOException?](http://forum.inductiveautomation.com/t/catch-ioexception/18612/2):
>
> Can you copy the full details of the error message? It’s probably calling out to open the file along a different code path; there may or may not be a way to work around the issue.
