Skip to content

Commit 12e90f1

Browse files
committed
chore: better runtime exceptions
1 parent ad00fbe commit 12e90f1

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/uipath_llamaindex/_cli/_runtime/_runtime.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
InputRequiredEvent,
1212
JsonPickleSerializer,
1313
)
14+
from llama_index.core.workflow.errors import WorkflowTimeoutError
1415
from llama_index.core.workflow.handler import WorkflowHandler
1516
from openinference.instrumentation.llama_index import (
1617
LlamaIndexInstrumentor,
@@ -114,15 +115,33 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
114115
if resume_trigger is None:
115116
try:
116117
output = await handler
118+
# catch any script exceptions
119+
except Exception as e:
120+
raise UiPathLlamaIndexRuntimeError(
121+
"AGENT_EXECUTION_FAILURE",
122+
"There was an exception while executing the agent ",
123+
str(e),
124+
UiPathErrorCategory.USER,
125+
) from e
126+
try:
117127
serialized_output = self._serialize_object(output)
118128
# create simple kvp from string
119129
if type(serialized_output) is str:
120130
serialized_output = {"result": serialized_output}
131+
121132
print(serialized_output)
122133
self.context.result = UiPathRuntimeResult(
123134
output=serialized_output,
124135
status=UiPathRuntimeStatus.SUCCESSFUL,
125136
)
137+
# check if workflow failed because of timeout constraints
138+
except WorkflowTimeoutError as e:
139+
raise UiPathLlamaIndexRuntimeError(
140+
"TIMEOUT_ERROR",
141+
"Workflow timed out",
142+
str(e),
143+
UiPathErrorCategory.USER,
144+
) from e
126145
except Exception as e:
127146
raise UiPathLlamaIndexRuntimeError(
128147
"SERIALIZE_OUTPUT_ERROR",

0 commit comments

Comments
 (0)