|
12 | 12 | from uipath.core.tracing import UiPathTraceManager |
13 | 13 |
|
14 | 14 | from uipath.runtime.errors import ( |
| 15 | + UiPathBaseRuntimeError, |
15 | 16 | UiPathErrorCategory, |
16 | 17 | UiPathErrorCode, |
17 | 18 | UiPathErrorContract, |
@@ -201,22 +202,19 @@ def __exit__(self, exc_type, exc_val, exc_tb): |
201 | 202 | self.result = UiPathRuntimeResult() |
202 | 203 |
|
203 | 204 | 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 | + ) |
220 | 218 |
|
221 | 219 | self.result.status = UiPathRuntimeStatus.FAULTED |
222 | 220 | self.result.error = error_info |
|
0 commit comments