Gateway script error handling best practise


I have making quite a few Gateway Tag Change Scripts that are doing various things, including interacting with SQL tables.

For my scripts running on a button click, it is obviously easy enough to display an errorBox to bring attention to an issue instantly. But with Gateway Event Scripts, you cannot do this.

Currently in my Gateway scripts I have some error checking, such as Try/Except whenever i do a runPrepQuery call.
The Except will log a stack trace error message which will show up in the Gateway console, as well as stored in an SQL table.

What do you guys think best practice would be for handling errors, and also creating a simple interface for an engineer/ admin to check any errors that may have occurred?
I don’t want errors to be occurring and no one knowing about it for some time.

Hi Richard,

I suppose you could use Ignition’s alarming system to notify you and/or others of Gateway script errors. But that might be annoying.

Since you are logging your Gateways script errors to a database you could create a simple Ignition window with a table that queries the database for all errors and shows them.

You could also install and use the WrapperLogViewer.proj Ignition project. This simple Ignition project gives a client that shows you the wrapper.log file and updates as the wrapper.log file changes. Not only will you see Gateway script errors but other problems in the Gateway as well. You can download this project from this blog post: … -or-client


For errors in critical scripts, consider writing the exception detail to a gateway string tag that one or more clients could display when non-blank. And/or set an alarm with a notification pipeline when that string changes.

Thanks for the tips.
I’m thinking of using Ignitions built in Alarming. I can set it to a certain user role level so it’s only visible to valid people, which will lower the “annoying” aspect.

I’ve tried putting an alarm on a string tag, but i can’t seem to get the alarm to execute. What alarm mode would you use to trigger when the string is non-blank?
I’ve tried triggering on “Not Equal to 0” and a few other modes but not having much success. Most of the modes seem more geared towards integer based alarms.

Got it working with the Alarm Mode “On Condition”, binding the “Is Active” to:


And i’ve added an Alarm Acknowledged script to clear the value of the string tag when the alarm is acknowledged.

1 Like