1616from uipath ._cli ._runtime ._contracts import (
1717 UiPathBaseRuntime ,
1818 UiPathErrorCategory ,
19+ UiPathErrorCode ,
1920 UiPathResumeTrigger ,
2021 UiPathRuntimeResult ,
2122 UiPathRuntimeStatus ,
2425
2526from .._utils ._config import LlamaIndexConfig
2627from ._context import UiPathLlamaIndexRuntimeContext
27- from ._exception import UiPathLlamaIndexRuntimeError
28+ from ._exception import LLamaIndexErrorCode , UiPathLlamaIndexRuntimeError
2829
2930logger = logging .getLogger (__name__ )
3031
@@ -97,7 +98,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
9798 # catch any script exceptions
9899 except Exception as e :
99100 raise UiPathLlamaIndexRuntimeError (
100- " AGENT_EXECUTION_FAILURE" ,
101+ LLamaIndexErrorCode . AGENT_EXECUTION_FAILURE ,
101102 "There was an exception while executing the agent " ,
102103 str (e ),
103104 UiPathErrorCategory .USER ,
@@ -128,14 +129,14 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
128129 # check if workflow failed because of timeout constraints
129130 except WorkflowTimeoutError as e :
130131 raise UiPathLlamaIndexRuntimeError (
131- " TIMEOUT_ERROR" ,
132+ LLamaIndexErrorCode . TIMEOUT_ERROR ,
132133 "Workflow timed out" ,
133134 str (e ),
134135 UiPathErrorCategory .USER ,
135136 ) from e
136137 except Exception as e :
137138 raise UiPathLlamaIndexRuntimeError (
138- " SERIALIZE_OUTPUT_ERROR" ,
139+ LLamaIndexErrorCode . SERIALIZE_OUTPUT_ERROR ,
139140 "Failed to serialize output" ,
140141 str (e ),
141142 UiPathErrorCategory .SYSTEM ,
@@ -162,7 +163,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
162163 raise
163164 detail = f"Error: { str (e )} "
164165 raise UiPathLlamaIndexRuntimeError (
165- " EXECUTION_ERROR" ,
166+ UiPathErrorCode . EXECUTION_ERROR ,
166167 "LlamaIndex Runtime execution failed" ,
167168 detail ,
168169 UiPathErrorCategory .USER ,
@@ -175,7 +176,7 @@ async def validate(self) -> None:
175176 self .context .input_json = json .loads (self .context .input )
176177 except json .JSONDecodeError as e :
177178 raise UiPathLlamaIndexRuntimeError (
178- " INPUT_INVALID_JSON" ,
179+ UiPathErrorCode . INPUT_INVALID_JSON ,
179180 "Invalid JSON input" ,
180181 "The input data is not valid JSON." ,
181182 UiPathErrorCategory .USER ,
@@ -185,7 +186,7 @@ async def validate(self) -> None:
185186 self .context .config = LlamaIndexConfig ()
186187 if not self .context .config .exists :
187188 raise UiPathLlamaIndexRuntimeError (
188- " CONFIG_MISSING" ,
189+ LLamaIndexErrorCode . CONFIG_MISSING ,
189190 "Invalid configuration" ,
190191 "Failed to load configuration" ,
191192 UiPathErrorCategory .DEPLOYMENT ,
@@ -195,7 +196,7 @@ async def validate(self) -> None:
195196 self .context .config .load_config ()
196197 except Exception as e :
197198 raise UiPathLlamaIndexRuntimeError (
198- " CONFIG_INVALID" ,
199+ LLamaIndexErrorCode . CONFIG_INVALID ,
199200 "Invalid configuration" ,
200201 f"Failed to load configuration: { str (e )} " ,
201202 UiPathErrorCategory .DEPLOYMENT ,
@@ -208,7 +209,7 @@ async def validate(self) -> None:
208209 elif not self .context .entrypoint :
209210 workflow_names = ", " .join (w .name for w in workflows )
210211 raise UiPathLlamaIndexRuntimeError (
211- " ENTRYPOINT_MISSING" ,
212+ UiPathErrorCode . ENTRYPOINT_MISSING ,
212213 "Entrypoint required" ,
213214 f"Multiple workflows available. Please specify one of: { workflow_names } ." ,
214215 UiPathErrorCategory .DEPLOYMENT ,
@@ -218,7 +219,7 @@ async def validate(self) -> None:
218219 self .workflow_config = self .context .config .get_workflow (self .context .entrypoint )
219220 if not self .workflow_config :
220221 raise UiPathLlamaIndexRuntimeError (
221- " WORKFLOW_NOT_FOUND" ,
222+ LLamaIndexErrorCode . WORKFLOW_NOT_FOUND ,
222223 "Workflow not found" ,
223224 f"Workflow '{ self .context .entrypoint } ' not found." ,
224225 UiPathErrorCategory .DEPLOYMENT ,
@@ -227,28 +228,28 @@ async def validate(self) -> None:
227228 self .context .workflow = await self .workflow_config .load_workflow ()
228229 except ImportError as e :
229230 raise UiPathLlamaIndexRuntimeError (
230- " WORKFLOW_IMPORT_ERROR" ,
231+ LLamaIndexErrorCode . WORKFLOW_IMPORT_ERROR ,
231232 "Workflow import failed" ,
232233 f"Failed to import workflow '{ self .context .entrypoint } ': { str (e )} " ,
233234 UiPathErrorCategory .USER ,
234235 ) from e
235236 except TypeError as e :
236237 raise UiPathLlamaIndexRuntimeError (
237- " WORKFLOW_TYPE_ERROR" ,
238+ LLamaIndexErrorCode . WORKFLOW_TYPE_ERROR ,
238239 "Invalid workflow type" ,
239240 f"Workflow '{ self .context .entrypoint } ' is not a valid `Workflow`: { str (e )} " ,
240241 UiPathErrorCategory .USER ,
241242 ) from e
242243 except ValueError as e :
243244 raise UiPathLlamaIndexRuntimeError (
244- " WORKFLOW_VALUE_ERROR" ,
245+ LLamaIndexErrorCode . WORKFLOW_VALUE_ERROR ,
245246 "Invalid workflow value" ,
246247 f"Invalid value in workflow '{ self .context .entrypoint } ': { str (e )} " ,
247248 UiPathErrorCategory .USER ,
248249 ) from e
249250 except Exception as e :
250251 raise UiPathLlamaIndexRuntimeError (
251- " WORKFLOW_LOAD_ERROR" ,
252+ LLamaIndexErrorCode . WORKFLOW_LOAD_ERROR ,
252253 "Failed to load workflow" ,
253254 f"Unexpected error loading workflow '{ self .context .entrypoint } ': { str (e )} " ,
254255 UiPathErrorCategory .USER ,
0 commit comments