-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from georgejecook/fix/node-task-return-fix
Fix/node task return fix
- Loading branch information
Showing
4 changed files
with
297 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function mc_private_taskExec(instance as dynamic) | ||
instance.delete("top") | ||
instance.delete("global") | ||
top = m.top | ||
m.append(instance) | ||
m.__isVMCreated = true | ||
m.new() | ||
m.top = top | ||
args = m.top.args | ||
maxTaskRetries = 1 | ||
if args <> invalid and args.maxTaskRetries <> invalid | ||
maxTaskRetries = args.maxTaskRetries | ||
end if | ||
lastResult = { isOk: false } | ||
attempt = 0 | ||
while attempt < maxTaskRetries | ||
try | ||
if m._execute <> invalid | ||
result = m._execute(args) | ||
else | ||
result = m.execute(args) | ||
end if | ||
if type(result) = "<uninitialized>" | ||
result = { isOk: false, message: "no result returned" } | ||
else if result = invalid or getInterface(result, "ifAssociativeArray") = invalid or result.isOk = invalid | ||
result = { isOk: true, data: result } | ||
end if | ||
if result.isOk = true | ||
return result | ||
else | ||
lastResult = result | ||
end if | ||
catch error | ||
m.log.error("error occurred executing task", m.top.subType(), m.top.id, error) | ||
if error <> invalid | ||
errorMessage = errorMessage.message | ||
else | ||
errorMessage = "" | ||
end if | ||
lastResult = { isOk: false, data: error, message: errorMessage } | ||
end try | ||
attempt++ | ||
end while | ||
|
||
return lastResult | ||
end function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.