What techniques work to handle errors in AppleScript so I can place a dialog?
Solution 1:
In general it's advisable to handle errors based on the error number and not on the text (which is language dependent and much more difficult to handle than some numbers). In addition start with just displaying the error number/messages to understand what really went wrong:
try
tell application "Finder" to open file file_path
on error error_message number error_number
display dialog "Error: " & the error_number & ": " & the error_message buttons {"OK"} default button 1
end try
Once you know the potential error codes you want to handle specifically you can extend this to
try
tell application "Finder" to open file file_path
on error error_message number error_number
if error_number = -1728 then
display dialog "Can't read file."
else
display dialog "Error: " & the error_number & ": " & the error_message buttons {"OK"} default button 1
end if
end try