[Request] Abort Macro IF Plugin Script Gets Error

@peternlewis, I'm writing my first KM Plug In Action, so I may have missed something.

If the Plugin script gets an error, how can we abort the Macro from within the Plugin script, without using any follow-on Actions?

The Plug In API predates being able to control the abort of actions, so I'm honestly not entirely sure how it behaves when the script fails. I don't think it really has any options to communication back its failure.

I'll look at updating it at some point in the future.

Peter, I hope sooner rather than later.
Based on my testing, I think you have all the info you need to abort the Macro if the Plugin Action fails.

Here's the KM Engine Log when it fails:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KM Engine Log When PlugIn Has Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2018-06-14 18:00:20 Assertion Failed: ActionCanFail(),  file: /Users/peter/Keyboard Maestro/Project/Source/Actions/HBaseAction.mm:1029, value: 0
2018-06-14 18:00:20 /Users/MyUserName/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Run AppleScript With Parameters V2 JMichaelTX/Main_JMTX.scpt: execution error: [ERROR]
Invalid Script Path: /Users/MyUserName/Documents/My KM Data/Scripts/XXXTest on run script.scpt

SCRIPT: KM Plugin - Run AppleScript File   Ver: 2.3
Error Number: -2700 (-2700)

2018-06-14 18:00:20 /Users/MyUserName/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Run AppleScript With Parameters V2 JMichaelTX/Main_JMTX.scpt: execution error: [ERROR]
Invalid Script Path: /Users/MyUserName/Documents/My KM Data/Scripts/XXXTest on run script.scpt

SCRIPT: KM Plugin - Run AppleScript File   Ver: 2.3
Error Number: -2700 (-2700)
 In macro “Using the KM PlugIn Run AppleScript with Parameters” (while executing JMTX Run AppleScript With Parameters V2).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Results Returned to PlugIn Action in Macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/Users/MyUserName/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Run AppleScript With Parameters V2 JMichaelTX/Main_JMTX.scpt: execution error: [ERROR]
Invalid Script Path: /Users/MyUserName/Documents/My KM Data/Scripts/XXXTest on run script.scpt

SCRIPT: KM Plugin - Run AppleScript File   Ver: 2.3
Error Number: -2700 (-2700)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error Msg I Set in PlugIn AppleScript 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[ERROR]
Invalid Script Path: /Users/MyUserName/Documents/My KM Data/Scripts/XXXTest on run script.scpt

SCRIPT: KM Plugin - Run AppleScript File   Ver: 2.3
Error Number: -2700 (-2700)

Thanks.

The next version will detect a failed status code returned from the script and (optionally) abort/report the failure.

2 Likes