Skip to content

Commit d2e8c4c

Browse files
fix: properly handle error types in context manager
1 parent 189bfde commit d2e8c4c

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/uipath/runtime/context.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from uipath.core.tracing import UiPathTraceManager
1313

1414
from uipath.runtime.errors import (
15+
UiPathBaseRuntimeError,
1516
UiPathErrorCategory,
1617
UiPathErrorCode,
1718
UiPathErrorContract,
@@ -201,22 +202,19 @@ def __exit__(self, exc_type, exc_val, exc_tb):
201202
self.result = UiPathRuntimeResult()
202203

203204
if exc_type:
204-
# Create error info from exception
205-
match exc_type:
206-
case UiPathFaultedTriggerError():
207-
error_info = UiPathRuntimeError.from_resume_trigger_error(
208-
exc_type
209-
).error_info
210-
case UiPathRuntimeError():
211-
error_info = exc_val.error_info
212-
case _:
213-
# Generic error
214-
error_info = UiPathErrorContract(
215-
code=f"ERROR_{exc_type.__name__}",
216-
title=f"Runtime error: {exc_type.__name__}",
217-
detail=str(exc_val),
218-
category=UiPathErrorCategory.UNKNOWN,
219-
)
205+
if issubclass(exc_type, UiPathFaultedTriggerError):
206+
error_info = UiPathRuntimeError.from_resume_trigger_error(
207+
exc_val
208+
).error_info
209+
elif issubclass(exc_type, UiPathBaseRuntimeError):
210+
error_info = exc_val.error_info
211+
else:
212+
error_info = UiPathErrorContract(
213+
code=f"ERROR_{exc_type.__name__}",
214+
title=f"Runtime error: {exc_type.__name__}",
215+
detail=str(exc_val),
216+
category=UiPathErrorCategory.UNKNOWN,
217+
)
220218

221219
self.result.status = UiPathRuntimeStatus.FAULTED
222220
self.result.error = error_info

0 commit comments

Comments
 (0)