So I wrote a small service that, when hotkey is pressed, captures a screenshot, uploads it to imgur and copies the link to the buffer. Thing is, if for some reason I decide NOT to capture anything and press Esc (or any other key), it breaks and displays an error. I want the service not to display an error when I manually cancel the procedure. How do I achieve that?
Edit: I have tried wrapping my script in try
and adding on error errMsg
before closing with end try
. It worked but I wonder if there's a more idiomatic solution.
try
statements anderror
handlers are how AppleScript deals with it.do shell script "afplay /System/Library/Sounds/Purr.aiff"
, in the past.