Est-ce que Applescript a une commande "exit" ou "die" similaire à PHP?

Comment puis-je jeter une erreur et la sortie dans Applescript? J'aimerais avoir quelque chose comme PHP die ou exit de commande de sorte que le "terminé" dialogue ne se déclenche pas.

function1()
display dialog "completed"

on function1()
    function2()
end function1

on function2()
    exit //what do i use here?
end function2

Voici ce que j'ai essayé avec la réponse qui a été posté ci-dessous:

function1()
display dialog "completed"

on function1()
    function2()
end function1

on function2()

    try
        display dialog "Do you want to catch an error?" buttons {"Continue without error", "Cause an error"} default button 2
        if button returned of result is "Cause an error" then
            error "I'm causing an error and thus it is caught in 'on error'"
        end if
        display dialog "completed without error"
    on error theError
        return theError -- this ends the applescript when an error occurs
    end try


end function2

source d'informationauteur cwd