system.tag.editTag unexpected behavior in try/except

Okay, so I’ve got it narrowed down pretty simple here. When changing tags I’d love a return value to let me know if it worked, but editTag doesn’t return anything so:

try:
	system.tag.editTag(tagPath='[default]This/doesnt/exist', overrides={"STATUS": {'Enabled':True}})
except:
	print( "didn't work" )

The tag doesn’t exist yet I get no error, whereas changing the tag provider

try:
	system.tag.editTag(tagPath='[deefoullt]Foo/bar/baz', overrides={"STATUS": {'Enabled':True}})
except:
	print( "didn't work" )

will print “didn’t work”

I hate to go back and read each and every one to check for failure, that seems… not best practice way of handling things

Anyone else run into this?

1 Like

Did you find a solution for this? I am running into the same problem with a gateway scoped script that isn’t throwing any error when system.tag.read("") is trying to read a tag that doesn’t exist.

For example:

try:
   tagValue = system.tag.read("Path/To/Machine%s/Tag" % (machineNo)).value
except:
   print 'error'

doesn’t print ‘error’ if the parameter machineNo ends up creating an invalid tag path.

This is quite problematic considering it is gateway scoped and i want to handle errors nicely in a logger or an alert somehow.

Found this thread to solve the problem:
http://forum.inductiveautomation.com/t/try-except-when-reading-tags/16179

1 Like

Thanks for updating the thread! I know I never came to a conclusion at the time b/c I would have posted the answer, I just went on with my life lol

I’d like to think I could figure it out now, I had only been working in Ignition for a couple weeks when I made the OP

Cheers