Generate alarm from exception and display on Alarm Status table

Hi All,
I have a situation where I am getting exceptions raised by a system.tag.write operation to an OPC server on a patchy network. Rather than having this exception bubble up to the UI, I would like to catch the exception and then display it in a alarm status table.
The alarm should automatically clear when I goes out of scope.

Can anyone advise that best way to achieve this?
Thanks in advance.

Probably easiest way is to just have in your scripting a

try:
     *Some Code*
except:
     system.tag.write("Code Fail Tag",1)

Just write to a memory tag and bind an alarm to that tag. Just don’t forget to reset that tag on a success or whatever.