Do Specified Piece of Script on Error.

Hi, I couldn’t find a good title so sorry for the confusion with it…

Basically, I have this script that sends an error report and asks the user to send it or not etc. but it’s like 50 lines or something and to tighten my code a little bit, I’d want to have something that when there’s an error (doesn’t matter what kind of error, but the error can occur in every handler), then do that piece of script.

Do I need to place the error script in a handler (how?) and do something like this ? :

try
--Do Action
on error
--Call Error Script
end error

Thanks in advance

Yes, if your error handler is large i’d put it in a subroutine and call the subroutine on error.

try
--Do Action
on error
handleError()
end error
on handleError()
--error handling script here
end handleError

Allright, thanks alot!