I’m trying to catch any possible errors arising from a SQL UPDATE (such as a duplicate key value) so that I can display a custom error message. I’ve tried the following codetry:
runUpdateQuery(blah)
except:
print "Error" without success - even when the update fails the standard warning appears and ‘Error’ never gets printed in the console.
Not currently, no. fpmi.db.runUpdateQuery catches errors internally and displays them. I’ve taken the liberty of moving this thread to the feature request forum.
But the exception is not being caught up. I am running 7.9.6 (b2018012914)
On the log it says:
Caused by: com.inductiveautomation.ignition.gateway.datasource.FaultedDatabaseConnectionException: The database connection 'scia' is FAULTED. See Gateway Status for details.
Any ideas are appreciated
Java exceptions are not subclasses of python’s Exception class, so your except class is excluding the java exceptions.
Try code something like this:
import java.lang.Exception
try:
# some code that can throw either jython or java exceptions
except java.lang.Exception, e:
# handle the java exception in e. You might need to use it's cause property to access nested exceptions
except Exception, e:
# handle a python exception as usual.