###What is Best Practice for Handling Script Errors in Execute Script Action?
Well, it is somewhat embarrassing to be asking this question after the many, many scripts I have written for the KM Execute Script Action. But recently I have found a need to handle ALL script errors properly in the KM macro.
Here was my first surprise:
KM provides a token called %ActionResult%, which does NOT seem to trap or identify script errors. It seems to always return "OK" even if the script has an error. See KM Wiki: ActionResult Token
I searched the KM Wiki, but could NOT find any info on handling script errors. See User Manual Page on Scripting.
@peternlewis, what am I missing? Is there some option, or better way to cause the "Execute Script" Action to return a non "OK" response when there is a script error?
Below is an example macro that demos the issue. Run this macro, but click on the "Cancel" button to the Choose Folder dialog.
Note the results display below: %ActionResult% returns "OK", but the KM Variable set by the Action clearly shows an ERROR.
So, this begs the question: What is the best way, in general, to trap for script errors, and cancel the Macro is there is an error?
I have started developing my own KM script error handling process, but I'll post that in a reply below.
If you have already developed a script error handling process, or have ideas for one, please reply.
###MACRO: Script ERROR Handling TEST
Script ERROR Handling TEST.kmmacros (6.3 KB)
###Results if User Cancels Choose Folder Script