What is Best Practice for Handling Script Errors in Execute Script Action?

All good points.

My example is just that, an example, not a finished product.

Actually, I think that if the script did not return "[ERROR]", and KM did not throw any errors, then it is a safe bet that it did actually run. Do you see some other issue?

It is easy enough to change the IF/THEN to a SWITCH/CASE, and handle each return type separately. That would probably be best in a finished product.

Well, there are two points:

  1. The error msg the user sees is different
  2. As I just said above, use SWITCH/CASE if you want to handle the different returns.

This is easily handled by:

  1. Uncheck "Include Errors" in the Execute Script action
  2. Use try/catch in the script

Yes, just like I did in my AppleScript example, and in the JXA example before that.

All said, I think we are in general agreement.

However, my main question was checking for "[ERROR]" vs "[OK]".
Do you have any thoughts on that?