Hi there,
Have you tried Try_Catch_Finally ?
Use try, catch, and finally blocks to respond to or handle terminating errors in scripts. The Trap statement can also be used to handle terminating errors in scripts.
about_Try_Catch_Finally
----------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept it as an answer–