88
99from pydantic import BaseModel
1010
11- from ._contracts import (
12- UiPathErrorCategory ,
13- UiPathRuntimeError ,
14- )
11+ from ._contracts import UiPathErrorCategory , UiPathErrorCode , UiPathRuntimeError
1512
1613T = TypeVar ("T" )
1714
@@ -28,15 +25,15 @@ def validate_entrypoint(self) -> None:
2825 """Validate runtime inputs."""
2926 if not self .entrypoint :
3027 raise UiPathRuntimeError (
31- " ENTRYPOINT_MISSING" ,
28+ UiPathErrorCode . ENTRYPOINT_MISSING ,
3229 "No entrypoint specified" ,
3330 "Please provide a path to a Python script." ,
3431 UiPathErrorCategory .USER ,
3532 )
3633
3734 if not os .path .exists (self .entrypoint ):
3835 raise UiPathRuntimeError (
39- " ENTRYPOINT_NOT_FOUND" ,
36+ UiPathErrorCode . ENTRYPOINT_NOT_FOUND ,
4037 "Script not found" ,
4138 f"Script not found at path { self .entrypoint } ." ,
4239 UiPathErrorCategory .USER ,
@@ -47,7 +44,7 @@ async def _execute_python_script(self, input_data: Any) -> Any:
4744 spec = importlib .util .spec_from_file_location ("dynamic_module" , self .entrypoint )
4845 if not spec or not spec .loader :
4946 raise UiPathRuntimeError (
50- " IMPORT_ERROR" ,
47+ UiPathErrorCode . IMPORT_ERROR ,
5148 "Module import failed" ,
5249 f"Could not load spec for { self .entrypoint } " ,
5350 UiPathErrorCategory .USER ,
@@ -58,7 +55,7 @@ async def _execute_python_script(self, input_data: Any) -> Any:
5855 spec .loader .exec_module (module )
5956 except Exception as e :
6057 raise UiPathRuntimeError (
61- " MODULE_EXECUTION_ERROR" ,
58+ UiPathErrorCode . MODULE_EXECUTION_ERROR ,
6259 "Module execution failed" ,
6360 f"Error executing module: { str (e )} " ,
6461 UiPathErrorCategory .USER ,
@@ -84,7 +81,7 @@ async def _execute_python_script(self, input_data: Any) -> Any:
8481 )
8582 except Exception as e :
8683 raise UiPathRuntimeError (
87- " FUNCTION_EXECUTION_ERROR" ,
84+ UiPathErrorCode . FUNCTION_EXECUTION_ERROR ,
8885 f"Error executing { func_name } function" ,
8986 f"Error: { str (e )} " ,
9087 UiPathErrorCategory .USER ,
@@ -114,7 +111,7 @@ async def _execute_python_script(self, input_data: Any) -> Any:
114111 )
115112 except Exception as e :
116113 raise UiPathRuntimeError (
117- " FUNCTION_EXECUTION_ERROR" ,
114+ UiPathErrorCode . FUNCTION_EXECUTION_ERROR ,
118115 f"Error executing { func_name } function with typed input" ,
119116 f"Error: { str (e )} " ,
120117 UiPathErrorCategory .USER ,
@@ -135,14 +132,14 @@ async def _execute_python_script(self, input_data: Any) -> Any:
135132 )
136133 except Exception as e :
137134 raise UiPathRuntimeError (
138- " FUNCTION_EXECUTION_ERROR" ,
135+ UiPathErrorCode . FUNCTION_EXECUTION_ERROR ,
139136 f"Error executing { func_name } function with dictionary input" ,
140137 f"Error: { str (e )} " ,
141138 UiPathErrorCategory .USER ,
142139 ) from e
143140
144141 raise UiPathRuntimeError (
145- " ENTRYPOINT_FUNCTION_MISSING" ,
142+ UiPathErrorCode . ENTRYPOINT_FUNCTION_MISSING ,
146143 "No entry function found" ,
147144 f"No main function (main, run, or execute) found in { self .entrypoint } " ,
148145 UiPathErrorCategory .USER ,
0 commit comments