Tags with Script Failures

Occasionally (more than I care to admit!) I have tags that will have a script “crash” (usually onChange scripts). I only find out about them when something goes wrong someplace else. Is there a way to query the tag database to see if there tags with script errors? Even better, is there a way to somehow notify me when there is a script error?

The wrapper file USUALLY has the error (sometimes it does not). I could write something that periodically checks the file for script errors but I was hoping for an easier and more elegant solution.


Put your script in a try except block, then log the error to a database or another tag or something like that.

    my script
    system.tag.write('error',"xTag script failed")

I would do something like:

	import traceback
	import sys
		your script here
	except Exception, err:
		exc_type, exc_value, exc_tb = sys.exc_info()
		errtb = traceback.format_exception(exc_type, exc_value, exc_tb)
		errStr = "Tag Path: "+str(tagPath)+" Tag Script Error: "+str(err)+errtb[1] + errtb[2]
		logger = system.util.getLogger("Tag test")

Its similar to what @dkhayes117 suggested but instead of using a tag on fail, it will use the gateway log and will tell you a little about the error including the line it comes from.

1 Like

Thanks. I used a modified version of @bpreston 's script and that will be helpful. It would be nice, though, to quickly find tags in error for any reason (evaluation, event script, etc.).