Cleaning Up Variables at the end of sub-macros

Most, if not all, Actions that encounter an error will automatically cause the Macro to abort, UNLESS you have unchecked one of these:

  • Timeout aborts macro
  • Failure aborts macro

Of course, if the KM Action has no way of knowing whether or not some external software (app, macOS, etc) has a failure, then this will not work.

For example, KM Action "Execute an AppleScript " does NOT abort even if the script returns an error.
So, in all my AppleScript and JXA scripts, I return "[ERROR]\n" and the error message. I then have a KM Group (set of actions) that check for the error and handle accordingly:

I just uploaded this macro (which is really just a Group Action) that I use:

MACRO: KM Group Action to Handle Script Error