Como implementar o tratamento de erros?

Meu script AutoIt gera um erro que eu quero manipular. Uma maneira que qualquer erro vá para uma função personalizada também funcionará. No VBA eu usoOnErrorGoTo, mas não consigo encontrar algo semelhante no AutoIt.

Meu código:

Func Start()
    While 1
        If ProcessExists ( "Photoshop.exe" ) <> 0 Then
            Sleep(5000)
        Else
            Local $sFile ="C:\Auto\CodeToBe\Batch\Image Process-50-2D v.2-" & $n & ".jsxbin"
            Local $iPID = ShellExecute($sFile)
            Sleep(10000)
            $n = $n+1
        EndIf
    WEnd
EndFunc

Ocorrerá um erro quando$n excede o número de arquivos nessa pasta. Eu tentei isso, mas não funcionou (na seção "HELP SECTION" e em uma postagem no fórum):

Global $iEventError = 0 ; To be checked to know if COM error occurs. Must be reset after handling.
Local $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler

Func Start()
    While 1
        If ProcessExists ( "Photoshop.exe" ) <> 0 Then
            Sleep(5000)
        Else
            Local $sFile ="C:\Auto\CodeToBe\Batch\Image Process-50-2D v.2-" & $n & ".jsxbin"
            Local $iPID = ShellExecute($sFile)
            If $iEventError Then
                MsgBox($MB_OK, "", "There was an error on the previous line.")
                $iEventError = 0 ; Reset after displaying a COM Error occurred
            EndIf
            Sleep(10000)
            $n = $n+1
        EndIf
    WEnd
EndFunc

; This is my custom error handler 
Func MyErrFunc() 
    Msgbox(0,"","ERROR GENERATED ON " & $n)
Endfunc

questionAnswers(3)

yourAnswerToTheQuestion