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

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

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:

try:
	your_queries
except java.lang.Throwable as e:
	handle_error
4 Likes

See Wiki - how to post code on this forum and then use the pencil icon to fix your post. Thanks.

thank you .its working now!