22from typing import Any , Awaitable , Callable , Optional
33
44from langgraph .graph .state import CompiledStateGraph , StateGraph
5- from uipath ._cli ._runtime ._contracts import (
6- UiPathErrorCategory ,
7- )
5+ from uipath ._cli ._runtime ._contracts import UiPathErrorCategory , UiPathErrorCode
86
97from .._utils ._graph import GraphConfig , LangGraphConfig
10- from ._exception import LangGraphRuntimeError
8+ from ._exception import LangGraphErrorCode , LangGraphRuntimeError
119
1210
1311class LangGraphJsonResolver :
@@ -36,7 +34,7 @@ async def _resolve(self, entrypoint: Optional[str]) -> StateGraph[Any, Any, Any]
3634 config = LangGraphConfig ()
3735 if not config .exists :
3836 raise LangGraphRuntimeError (
39- " CONFIG_MISSING" ,
37+ LangGraphErrorCode . CONFIG_MISSING ,
4038 "Invalid configuration" ,
4139 "Failed to load configuration" ,
4240 UiPathErrorCategory .DEPLOYMENT ,
@@ -46,7 +44,7 @@ async def _resolve(self, entrypoint: Optional[str]) -> StateGraph[Any, Any, Any]
4644 config .load_config ()
4745 except Exception as e :
4846 raise LangGraphRuntimeError (
49- " CONFIG_INVALID" ,
47+ LangGraphErrorCode . CONFIG_INVALID ,
5048 "Invalid configuration" ,
5149 f"Failed to load configuration: { str (e )} " ,
5250 UiPathErrorCategory .DEPLOYMENT ,
@@ -59,7 +57,7 @@ async def _resolve(self, entrypoint: Optional[str]) -> StateGraph[Any, Any, Any]
5957 elif not entrypoint :
6058 graph_names = ", " .join (g .name for g in graphs )
6159 raise LangGraphRuntimeError (
62- " ENTRYPOINT_MISSING" ,
60+ UiPathErrorCode . ENTRYPOINT_MISSING ,
6361 "Entrypoint required" ,
6462 f"Multiple graphs available. Please specify one of: { graph_names } ." ,
6563 UiPathErrorCategory .DEPLOYMENT ,
@@ -69,7 +67,7 @@ async def _resolve(self, entrypoint: Optional[str]) -> StateGraph[Any, Any, Any]
6967 self .graph_config = config .get_graph (entrypoint )
7068 if not self .graph_config :
7169 raise LangGraphRuntimeError (
72- " GRAPH_NOT_FOUND" ,
70+ LangGraphErrorCode . GRAPH_NOT_FOUND ,
7371 "Graph not found" ,
7472 f"Graph '{ entrypoint } ' not found." ,
7573 UiPathErrorCategory .DEPLOYMENT ,
@@ -83,28 +81,28 @@ async def _resolve(self, entrypoint: Optional[str]) -> StateGraph[Any, Any, Any]
8381 )
8482 except ImportError as e :
8583 raise LangGraphRuntimeError (
86- " GRAPH_IMPORT_ERROR" ,
84+ LangGraphErrorCode . GRAPH_IMPORT_ERROR ,
8785 "Graph import failed" ,
8886 f"Failed to import graph '{ entrypoint } ': { str (e )} " ,
8987 UiPathErrorCategory .USER ,
9088 ) from e
9189 except TypeError as e :
9290 raise LangGraphRuntimeError (
93- " GRAPH_TYPE_ERROR" ,
91+ LangGraphErrorCode . GRAPH_TYPE_ERROR ,
9492 "Invalid graph type" ,
9593 f"Graph '{ entrypoint } ' is not a valid StateGraph or CompiledStateGraph: { str (e )} " ,
9694 UiPathErrorCategory .USER ,
9795 ) from e
9896 except ValueError as e :
9997 raise LangGraphRuntimeError (
100- " GRAPH_VALUE_ERROR" ,
98+ LangGraphErrorCode . GRAPH_VALUE_ERROR ,
10199 "Invalid graph value" ,
102100 f"Invalid value in graph '{ entrypoint } ': { str (e )} " ,
103101 UiPathErrorCategory .USER ,
104102 ) from e
105103 except Exception as e :
106104 raise LangGraphRuntimeError (
107- " GRAPH_LOAD_ERROR" ,
105+ LangGraphErrorCode . GRAPH_LOAD_ERROR ,
108106 "Failed to load graph" ,
109107 f"Unexpected error loading graph '{ entrypoint } ': { str (e )} " ,
110108 UiPathErrorCategory .USER ,
0 commit comments