diff --git a/seeds/pythonboard/src/breadboard.py b/seeds/pythonboard/src/breadboard.py index 653b3ca2..02478591 100644 --- a/seeds/pythonboard/src/breadboard.py +++ b/seeds/pythonboard/src/breadboard.py @@ -156,7 +156,10 @@ async def run( if type(handler) == javascript.proxy.Proxy: # This can possibly be wrapped in an AsyncTask instead of a trivial coroutine async def await_js(func, args): - res = func(args) + if func.invoke: + res = func.invoke(args) + else: + res = func(args) # Outputs can be a javascript proxy, so convert to dict try: res = {k: res[k] for k in res} diff --git a/seeds/pythonboard/src/traversal/iterator.py b/seeds/pythonboard/src/traversal/iterator.py index c9c82d4a..cd2b0685 100644 --- a/seeds/pythonboard/src/traversal/iterator.py +++ b/seeds/pythonboard/src/traversal/iterator.py @@ -45,13 +45,22 @@ def _processCompletedNode( if outputs.get("$error") and not any(e.out == "$error" for e in newOpportunities): # If the node threw an exception and it wasn't routed via $error, # throw it again. This will cause the traversal to stop. - raise Exception( - "Uncaught exception in node handler. " + - "Catch by wiring up the $error output.", - { - "cause": outputs["$error"], - } - ) + if isinstance(outputs.get("$error").error, Exception): + raise Exception( + "Uncaught exception in node handler. " + + "Catch by wiring up the $error output.", + { + "cause": outputs["$error"], + } + ) from outputs.get("$error").error + else: + raise Exception( + "Uncaught exception in node handler. " + + "Catch by wiring up the $error output.", + { + "cause": outputs["$error"], + } + ) @staticmethod async def processAllPendingNodes( @@ -89,7 +98,8 @@ async def _promise(): # If not already present, add inputs and descriptor along for # context and to support retries. if "$error" in outputs: - outputs["$error"] = outputs["$error"] | { + error_dict = {k: outputs["$error"][k] for k in outputs["$error"]} + outputs["$error"] = error_dict | { "descriptor": descriptor, "inputs": inputs, }