Python try/exepts in Ignition

Is there a type error that will accept sql database writes in Ignition like the first one?


 Lots of things that might not work
 system.db.runPrepUpdate("INSERT INTO table VALUES ('lots of things')", [lots of things])

except SQLError:
system.gui.messageBox(“Sql Server rejected your insert”)

something happened that did not have to do with your sql statement.

No we just throw a general exception on those functions. You have to put a try block around each database call.

Sometimes there is a situation, that connection to PLC is missing, but some scripts are trying to write some values into the PLC. It is done by using system.tag.writeToTag function. The problem is that in case of connection problem, there is common Error box displayed. We would like to replace the Error box with something nicer :slight_smile:

We have tried to use try: except: but it seems that it does not work with system.tag.writeToTag function. Are there any ways to overcome the Error boxes when using system.tag.writeToTag function?

Thank you!

With the system.tag.writeToTag, you have to suppress the errors like this:system.tag.writeToTag("Path/To/Tag", value, 1)The last argument is a 1.

Thank you! Found from help manual, that the last parameter stands for supressing errors.