带有图标停止和系统事件的 Applescript 和显示对话框

Applescript & display dialog with icon stop & System Events

我有一个完全让我发疯的愚蠢问题。我需要访问 plist 文件中的一个节点,如果出现问题,我希望显示一个带有 'stop' 图标的对话框。这是代码:

tell application "System Events"
    tell property list file (plistFile as text)
        try
            tell contents
                set backupDayTemp to value of property list item plistElementBackupDay of property list item chosenBackupDisk
            end tell
        on error m number n from f to t partial result p
            if n = -1728 then
                display dialog "Can't find " & plistElementBackupDay & " key for disk " & chosenBackupDisk & " in plist file." buttons {"Damn", "Oh dear"} default button "Damn" with title myName with icon stop
                return
            else
                -- otherwise, pass the error on
                error m number n from f to t partial result p
            end if
        end try
    end tell
end tell

似乎编译器认为系统事件应该理解标记 "stop",因为它是粗体蓝色字体,而不是通常使用的紫色斜体。当错误处理程序是运行 我被告知“系统事件发生错误:属性 列表文件 [文件路径] 不理解 "stop" 消息”。

我的问题是:到底如何告诉系统事件该令牌不适用于它?我试过在 display dialog 前面放一个 tell me to,但这没有帮助。我也试过 using terms from application "Standard Additions" 但是当我 运行 它时,我只是被要求找到标准添加的字典。

把我的头发扯掉!!!

最简单的解决方案是将错误处理放在应用程序告诉块之外

try
    tell application "System Events"
        tell property list file (plistFile as text)
            tell contents
                set backupDayTemp to value of property list item plistElementBackupDay of property list item chosenBackupDisk
            end tell
        end tell
    end tell
on error m number n from f to t partial result p
    if n = -1728 then
        display dialog "Can't find " & plistElementBackupDay & " key for disk " & chosenBackupDisk & " in plist file." buttons {"Damn", "Oh dear"} default button "Damn" with title myName with icon stop
        return
    else
        -- otherwise, pass the error on
        error m number n from f to t partial result p
    end if
end try