Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit f1a9d04

Browse files
authored
Merge pull request #34 from UiPath/fix/pending_trigger_error
fix: trigger errors ctor
2 parents 7122f79 + 7b19cf9 commit f1a9d04

7 files changed

Lines changed: 392 additions & 298 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ wheels/
2828

2929
.cache/*
3030
.cache
31+
32+
.claude

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-core"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
description = "UiPath Core abstractions"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/core/errors/errors.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class UiPathFaultedTriggerError(Exception):
1717

1818
category: ErrorCategory
1919
message: str
20+
detail: str
21+
22+
def __init__(self, category: ErrorCategory, message: str, detail: str = ""):
23+
"""Initialize the UiPathFaultedTriggerError."""
24+
self.category = category
25+
self.message = message
26+
self.detail = detail
27+
super().__init__(f"{message}: {detail}" if detail else message)
2028

2129

2230
class UiPathPendingTriggerError(UiPathFaultedTriggerError):

tests/errors/__init__.py

Whitespace-only changes.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""Tests for UiPath trigger error classes."""
2+
3+
from uipath.core.errors import (
4+
ErrorCategory,
5+
UiPathFaultedTriggerError,
6+
UiPathPendingTriggerError,
7+
)
8+
9+
10+
class TestUiPathFaultedTriggerError:
11+
"""Test UiPathFaultedTriggerError constructor and behavior."""
12+
13+
def test_init_with_detail(self) -> None:
14+
"""Test that category, message, and detail are stored and str includes both."""
15+
err = UiPathFaultedTriggerError(
16+
category=ErrorCategory.USER,
17+
message="Something failed",
18+
detail="missing input",
19+
)
20+
assert err.category == ErrorCategory.USER
21+
assert err.message == "Something failed"
22+
assert err.detail == "missing input"
23+
assert str(err) == "Something failed: missing input"
24+
25+
def test_init_without_detail(self) -> None:
26+
"""Test that detail defaults to empty string and str is just the message."""
27+
err = UiPathFaultedTriggerError(
28+
category=ErrorCategory.SYSTEM,
29+
message="Internal error",
30+
)
31+
assert err.category == ErrorCategory.SYSTEM
32+
assert err.message == "Internal error"
33+
assert err.detail == ""
34+
assert str(err) == "Internal error"
35+
36+
def test_is_exception(self) -> None:
37+
"""Test that the error can be raised and caught as an Exception."""
38+
with __import__("pytest").raises(UiPathFaultedTriggerError, match="boom"):
39+
raise UiPathFaultedTriggerError(
40+
category=ErrorCategory.DEPLOYMENT,
41+
message="boom",
42+
)
43+
44+
45+
class TestUiPathPendingTriggerError:
46+
"""Test UiPathPendingTriggerError inherits correctly."""
47+
48+
def test_inherits_faulted_trigger_error(self) -> None:
49+
"""Test that PendingTriggerError is a subclass of FaultedTriggerError."""
50+
err = UiPathPendingTriggerError(
51+
category=ErrorCategory.UNKNOWN,
52+
message="Pending",
53+
detail="waiting for response",
54+
)
55+
assert isinstance(err, UiPathFaultedTriggerError)
56+
assert err.category == ErrorCategory.UNKNOWN
57+
assert str(err) == "Pending: waiting for response"
58+
59+
def test_catchable_as_faulted(self) -> None:
60+
"""Test that PendingTriggerError can be caught as FaultedTriggerError."""
61+
with __import__("pytest").raises(UiPathFaultedTriggerError):
62+
raise UiPathPendingTriggerError(
63+
category=ErrorCategory.USER,
64+
message="still pending",
65+
)

tests/tracing/test_span_filtering.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def test_filter_drops_non_matching_spans(self):
3535
mock_exporter.export.return_value = SpanExportResult.SUCCESS
3636

3737
settings = UiPathTraceSettings(
38-
span_filter=lambda span: span.attributes is not None
39-
and span.attributes.get("keep") is True
38+
span_filter=lambda span: (
39+
span.attributes is not None and span.attributes.get("keep") is True
40+
)
4041
)
4142
trace_manager = UiPathTraceManager()
4243
trace_manager.add_span_exporter(mock_exporter, batch=False, settings=settings)
@@ -208,12 +209,14 @@ def test_different_filters_per_exporter(self):
208209
mock_exporter_b.export.return_value = SpanExportResult.SUCCESS
209210

210211
settings_a = UiPathTraceSettings(
211-
span_filter=lambda span: span.attributes is not None
212-
and span.attributes.get("dest") == "a"
212+
span_filter=lambda span: (
213+
span.attributes is not None and span.attributes.get("dest") == "a"
214+
)
213215
)
214216
settings_b = UiPathTraceSettings(
215-
span_filter=lambda span: span.attributes is not None
216-
and span.attributes.get("dest") == "b"
217+
span_filter=lambda span: (
218+
span.attributes is not None and span.attributes.get("dest") == "b"
219+
)
217220
)
218221

219222
trace_manager = UiPathTraceManager()

0 commit comments

Comments
 (0)