# Catching exception in webdev doPost

**URL:** <https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [August 2, 2023, 9:15pm UTC](https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318 "2023-08-02T21:15:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpmccormick](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wpmccormick/32/13940_2.png) [@wpmccormick](https://forum.inductiveautomation.com/u/wpmccormick)\
**Post date:** [August 2, 2023, 9:15pm UTC](https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318/1 "2023-08-02T21:15:25Z")

</div>

I have a try/except block inside a for loop on a doPost.

A named query is executed for each element inside the loop. If there is an exception, I catch it and continue to try the next element.

Since the try/except is inside the for loop, I wouldn't think that I need an explicit continue statement, but whether I use one or not, the for loop drops out and no other elements are tried.

Continuing (with and without an explicit continue) works in straight python and in the Script Console, so is there some issue/caveat with webdev?

Cheers!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 2, 2023, 9:24pm UTC](https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318/2 "2023-08-02T21:24:06Z")

</div>

The exception being thrown might be a Java exception, rather than a Python exception?

> [@Retrieving RAISERROR from Stored Procedure](https://forum.inductiveautomation.com/t/retrieving-raiserror-from-stored-procedure/16971/4):
>
> Use separate catch clauses. One for java exceptions, one for python: import java.lang.Exception try: call = system.db.createSProcCall(procedureName='save') call.registerInParam('name', system.db.VARCHAR, None) system.db.execSProcCall(call) except java.lang.Exception, e: /\* Print exceptions originating in Java \*/ print e except Exception, e: /\* Print other exceptions \*/ print e

---

<div class="post-metadata">

**Author:** ![wpmccormick](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wpmccormick/32/13940_2.png) [@wpmccormick](https://forum.inductiveautomation.com/u/wpmccormick)\
**Post date:** [August 2, 2023, 9:30pm UTC](https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318/3 "2023-08-02T21:30:50Z")

</div>

Yea, that works. But it's still a head scratcher because the plain vanilla _except Exception as e_: did catch (and logged a message for me).

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 2, 2023, 9:38pm UTC](https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318/4 "2023-08-02T21:38:58Z")

</div>

Right, it probably was caught at the outer layer of "the webdev module". Unless you're saying you caught the message but your for loop still dropped out.

---

<div class="post-metadata">

**Author:** ![wpmccormick](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wpmccormick/32/13940_2.png) [@wpmccormick](https://forum.inductiveautomation.com/u/wpmccormick)\
**Post date:** [August 2, 2023, 9:48pm UTC](https://forum.inductiveautomation.com/t/catching-exception-in-webdev-dopost/77318/5 "2023-08-02T21:48:52Z")

</div>

Yes I didn't notice it was the PythonResource logger that had the message.

Thanks!
