Skip to content

Commit 37393ee

Browse files
authored
Merge pull request #40 from UiPath/chore/statuses
feat: convert faulted trigger errors to runtime errors
2 parents e824efd + f97a942 commit 37393ee

File tree

7 files changed

+42
-19
lines changed

7 files changed

+42
-19
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-runtime"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-core>=0.0.5, <0.1.0",
8+
"uipath-core>=0.0.9, <0.1.0",
99
]
1010
classifiers = [
1111
"Intended Audience :: Developers",

src/uipath/runtime/context.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Any
99

1010
from pydantic import BaseModel, ConfigDict
11+
from uipath.core.errors import UiPathFaultedTriggerError
1112
from uipath.core.tracing import UiPathTraceManager
1213

1314
from uipath.runtime.errors import (
@@ -167,16 +168,21 @@ def __exit__(self, exc_type, exc_val, exc_tb):
167168

168169
if exc_type:
169170
# Create error info from exception
170-
if isinstance(exc_val, UiPathRuntimeError):
171-
error_info = exc_val.error_info
172-
else:
173-
# Generic error
174-
error_info = UiPathErrorContract(
175-
code=f"ERROR_{exc_type.__name__}",
176-
title=f"Runtime error: {exc_type.__name__}",
177-
detail=str(exc_val),
178-
category=UiPathErrorCategory.UNKNOWN,
179-
)
171+
match exc_type:
172+
case UiPathFaultedTriggerError():
173+
error_info = UiPathRuntimeError.from_resume_trigger_error(
174+
exc_type
175+
).error_info
176+
case UiPathRuntimeError():
177+
error_info = exc_val.error_info
178+
case _:
179+
# Generic error
180+
error_info = UiPathErrorContract(
181+
code=f"ERROR_{exc_type.__name__}",
182+
title=f"Runtime error: {exc_type.__name__}",
183+
detail=str(exc_val),
184+
category=UiPathErrorCategory.UNKNOWN,
185+
)
180186

181187
self.result.status = UiPathRuntimeStatus.FAULTED
182188
self.result.error = error_info

src/uipath/runtime/debug/runtime.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import logging
55
from typing import Any, AsyncGenerator, cast
66

7+
from uipath.core.errors import UiPathPendingTriggerError
8+
79
from uipath.runtime.base import (
810
UiPathExecuteOptions,
911
UiPathRuntimeProtocol,
@@ -273,7 +275,8 @@ async def _poll_trigger(
273275

274276
except UiPathDebugQuitError:
275277
raise
276-
except Exception as e:
278+
279+
except UiPathPendingTriggerError as e:
277280
await self.debug_bridge.emit_state_update(
278281
UiPathRuntimeStateEvent(
279282
node_name="<polling>",

src/uipath/runtime/errors/codes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class UiPathErrorCode(str, Enum):
2424
INPUT_INVALID_JSON = "INPUT_INVALID_JSON"
2525

2626
# HITL (Human-In-The-Loop) related errors
27+
RESUME_TRIGGER_ERROR = "RESUME_TRIGGER_ERROR"
2728
INVOKED_PROCESS_FAILURE = "INVOKED_PROCESS_FAILURE"
2829
CREATE_RESUME_TRIGGER_ERROR = "CREATE_RESUME_TRIGGER_ERROR"
2930
RETRIEVE_RESUME_TRIGGER_ERROR = "RETRIEVE_PAYLOAD_ERROR"

src/uipath/runtime/errors/exception.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import traceback
55
from typing import Any
66

7+
from uipath.core.errors import UiPathFaultedTriggerError
8+
79
from uipath.runtime.errors.codes import UiPathErrorCode
810
from uipath.runtime.errors.contract import UiPathErrorCategory, UiPathErrorContract
911

@@ -99,3 +101,15 @@ def __init__(
99101
prefix=prefix,
100102
include_traceback=include_traceback,
101103
)
104+
105+
@classmethod
106+
def from_resume_trigger_error(
107+
cls, exc: UiPathFaultedTriggerError
108+
) -> "UiPathRuntimeError":
109+
"""Create UiPathRuntimeError from UiPathFaultedTriggerError."""
110+
return cls(
111+
code=UiPathErrorCode.RESUME_TRIGGER_ERROR,
112+
title="Resume trigger error",
113+
detail=exc.message,
114+
category=UiPathErrorCategory(exc.category),
115+
)

src/uipath/runtime/resumable/runtime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ async def execute(
6767

6868
# Execute the delegate
6969
result = await self.delegate.execute(input, options=options)
70-
7170
# If suspended, create and persist trigger
7271
return await self._handle_suspension(result)
7372

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)