Failing Actions and Shell Scripts

Does anyone have a suggestion for logging these fails? I have macros that perform a number of shell scripts to add info to leads in a CRM. It works great but after a few hours of it running it fails with this.

If I can somehow track and understand these errors I could have the macros restart if the error happens. or prevent the errors entirely.

Right now I am just tracking all of the executing macro IDS and every time an individual macro runs setting a variable with those macros running ID. If the current IDS does not contain the individual ids then it executes it.

Another thing I noticed to is my keyboard Maestro Engine turned off on its own. How can I prevent this?

Have you looked in the KM log file?

Unfortunately KM does NOT provide any type of try/catch error handler, so you have to roll your own for each and every case.

For the Actions that are consistently failing, you can do this:

  • Change the option in the Action Gear menu to Uncheck the "Failure terminates macro":
    • image
  • Then after that Action, using KM IF/THEN action to check for the %ActionResult% value. If not "OK", then it failed, and you can add whatever actions you want to deal with the failure.

You may also find this macro helpful:

MACRO: Display Last KM Macro Error Ver 4 [Pub]

As @DanThomas suggested you can view the KM Engine log to find these macro failures. My above Macro provides an option to easily get/display the last N entries in the log.

Thanks, @JMichaelTX , for stating that so well.

@Byrein You could set up the "if" part in in KMFAM to make it easy to replicate. You could use the %ExecutingThisMacro% token to make a generic error message that could help pinpoint the issues.

Regarding actually logging the errors, I had forgotten about this set of macros I wrote, which I still use: Write to Log File. Let me know if you need help with them - I can show you how I use them.

You two are great! Thank you so much and im sure ill have some questions.

1 Like

Another solution I found helpful to catching errors is "the last action result"

Screen Shot 2021-08-15 at 7.07.01 PM