# system.tag.editTag unexpected behavior in try/except

**URL:** <https://forum.inductiveautomation.com/t/system-tag-edittag-unexpected-behavior-in-try-except/19887>\
**Category:** Ignition\
**Created:** [September 28, 2018, 6:13pm UTC](https://forum.inductiveautomation.com/t/system-tag-edittag-unexpected-behavior-in-try-except/19887 "2018-09-28T18:13:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [September 28, 2018, 6:13pm UTC](https://forum.inductiveautomation.com/t/system-tag-edittag-unexpected-behavior-in-try-except/19887/1 "2018-09-28T18:13:50Z")

</div>

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:

```auto
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

```auto
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?

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [September 13, 2019, 2:36am UTC](https://forum.inductiveautomation.com/t/system-tag-edittag-unexpected-behavior-in-try-except/19887/2 "2019-09-13T02:36:13Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [September 13, 2019, 2:38am UTC](https://forum.inductiveautomation.com/t/system-tag-edittag-unexpected-behavior-in-try-except/19887/3 "2019-09-13T02:38:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [September 13, 2019, 3:46am UTC](https://forum.inductiveautomation.com/t/system-tag-edittag-unexpected-behavior-in-try-except/19887/4 "2019-09-13T03:46:35Z")

</div>

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
