Есть ли в Applescript команда «exit» или «die», аналогичная PHP?

Как я могу выдать ошибку и выйти из Applescript? Я хотел бы иметь что-то вроде команды PHP die или exit , чтобы диалоговое окно «Завершено» не запускалось.

function1()
display dialog "completed"

on function1()
    function2()
end function1

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

Вот что я пробовал с ответом, опубликованным ниже:

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
10
задан cwd 21 November 2011 в 22:55
поделиться