# Try Catch Block is not Working for any query type like NamedQuery

**URL:** <https://forum.inductiveautomation.com/t/try-catch-block-is-not-working-for-any-query-type-like-namedquery/89020>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [April 18, 2024, 7:17am UTC](https://forum.inductiveautomation.com/t/try-catch-block-is-not-working-for-any-query-type-like-namedquery/89020 "2024-04-18T07:17:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prajwal\_Dhumal](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@Prajwal\_Dhumal](https://forum.inductiveautomation.com/u/Prajwal_Dhumal)\
**Post date:** [April 18, 2024, 7:17am UTC](https://forum.inductiveautomation.com/t/try-catch-block-is-not-working-for-any-query-type-like-namedquery/89020/1 "2024-04-18T07:17:05Z")

</div>

try:  
parameters ={'Facility':'P1C1',  
'Company' : 'Ignition',  
'Division' : 'Designer',  
'Short':'abcd',  
'Medium':'abcd',  
'Extended':'abcd'  
}  
system.perspective.print("before query execution ")  
system.db.runNamedQuery('Stored Procedures/FacilityInsert', parameters)  
system.perspective.print("after Execution")  
except Exception as e:  
print(e)  
So Please take look at this simple code where if I'm giving wrong data, the NamedQuery is giving error and the further executions is terminated. cause this try catch block is not woring for it. can you please help me with this

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 18, 2024, 8:04am UTC](https://forum.inductiveautomation.com/t/try-catch-block-is-not-working-for-any-query-type-like-namedquery/89020/2 "2024-04-18T08:04:15Z")

</div>

When posting code, use the code formatting tool.  
You can edit your post to add proper formatting.

Queries raise java errors, so you need to catch java errors:

```python
try:
	your_queries
except java.lang.Throwable as e:
	handle_error

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 18, 2024, 8:57am UTC](https://forum.inductiveautomation.com/t/try-catch-block-is-not-working-for-any-query-type-like-namedquery/89020/3 "2024-04-18T08:57:12Z")

</div>

See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831) and then use the pencil icon to fix your post. Thanks.

---

<div class="post-metadata">

**Author:** ![Prajwal\_Dhumal](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@Prajwal\_Dhumal](https://forum.inductiveautomation.com/u/Prajwal_Dhumal)\
**Post date:** [April 19, 2024, 6:26am UTC](https://forum.inductiveautomation.com/t/try-catch-block-is-not-working-for-any-query-type-like-namedquery/89020/4 "2024-04-19T06:26:16Z")

</div>

thank you .its working now!
