# Tag event script fails, same code in button works

**URL:** <https://forum.inductiveautomation.com/t/tag-event-script-fails-same-code-in-button-works/37019>\
**Category:** General Discussion\
**Tags:** ignition79\
**Created:** [July 23, 2020, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-fails-same-code-in-button-works/37019 "2020-07-23T21:00:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [July 23, 2020, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-fails-same-code-in-button-works/37019/1 "2020-07-23T21:00:39Z")

</div>

Sometimes my tag event scripts stop working and will not restart until I restart the gateway. Calling the script from the Script console or from a button on a project window works just fine all the time, even when the tag event scripts stop working. I suspect I am getting some exceptions swallowed up and not handled properly by I can’t find them, even using system.util.getLogger calls in my shared function.

Using gateway 7.9.14

Question:

1. Do all tag events “value changed” scripts run on the same thread ?
2. If there is an exception on in the tag event context does it kill all the other tag events ?
3. How do you catch exceptions that run on the tag event context ?

I wrote a shared (global) routine to copy tag values from one UDT to another UDT where the tag names match.  
I am calling this in a “value changed” event on a system expression tag. The system expression tag contains the expression “getSecond(now(1))” so it changes every second.

The “value changed” script is called like this:

```auto
shared.OPCUAservices.Steering_OPCUA_service.writeToSubscribers()

```

That function basically makes two lists of matching tag paths and uses functions to read values from one list of tags and write them to another list of values.

```auto
tags = system.tag.readAll(readTagPathList)
.... more code to make a list of tag values
system.tag.writeAll(writeTagPathList,tagValues)

```

All tag paths complete with the device prefix. For example: “[s1500]\_TESTJVSC/\_test”
