I think my modular replacement for executeCommand()
is working. Github repo for modularExecuteCommand.
It should be a drop-in replacement for executeCommand()
. It works by modifying PendingCommandToks.executePending()
to use a method on the new modularExecuteCommand
singleton instead of adv3’s builtin executeCommand()
function (which is untouched).
There’s no particular reason why you’d need this if you weren’t looking to fiddle around with the command execution cycle. But if you are, the intent is to make it easier to twiddle individual bits (like doing a modify modularExecuteCommand
to replace a single method) without having to replace the entire hundreds-of-lines-long executeCommand()
.
In addition to being able to replace/modify individual steps of the process, the module implements “standalone” exception handlers for the inner loop. In the stock executeCommand()
there’s a try
block followed by a sequence of hardcoded catch()
handlers. The module has a single try/catch
block, and implements a ModularExceptionHandler
class. You can define instances of ModularExceptionHandler
and they’re automagically be used for any matching exceptions thrown during processing. E.g., the replacement for the stock ParseFailureException
catch()
block looks like:
mehParseFailure: ModularExceptionHandler
type = ParseFailureException
handle(rfExc) {
_debug('===ParseFailureException===');
rfExc.notifyActor(execState.dstActor, execState.srcActor);
clearExecState();
return(mehReturn);
}
;
The type
determines what kind of exception it handles, and the handle()
method does the handling, its arg being the exception object thrown during processing.
Anyway, like I said this is something that most people won’t have any use for, but I’m putting it out there anyway. I’m in the process of refactoring the noun-as-verb stuff (where all of this originated) to use the new executeCommand()
replacement.