44import logging
55from typing import Any , AsyncGenerator , cast
66
7+ from uipath .core .exceptions import UiPathResumeTriggerException , UiPathResumeTriggerPendingException
8+
79from uipath .runtime .base import (
810 UiPathExecuteOptions ,
911 UiPathRuntimeProtocol ,
1517 UiPathDebugBridgeProtocol ,
1618 UiPathDebugQuitError ,
1719)
20+ from uipath .runtime .errors import UiPathRuntimeError , UiPathErrorCode
21+ from uipath .runtime .errors .exception import handle_runtime_exceptions
1822from uipath .runtime .events import (
1923 UiPathRuntimeEvent ,
2024 UiPathRuntimeStateEvent ,
@@ -54,6 +58,7 @@ def __init__(
5458 raise ValueError ("trigger_poll_interval must be >= 0" )
5559 self .trigger_poll_interval = trigger_poll_interval
5660
61+ @handle_runtime_exceptions
5762 async def execute (
5863 self ,
5964 input : dict [str , Any ] | None = None ,
@@ -71,6 +76,7 @@ async def execute(
7176 else UiPathRuntimeResult (status = UiPathRuntimeStatus .SUCCESSFUL )
7277 )
7378
79+ @handle_runtime_exceptions
7480 async def stream (
7581 self ,
7682 input : dict [str , Any ] | None = None ,
@@ -271,9 +277,11 @@ async def _poll_trigger(
271277
272278 await self ._wait_with_quit_check ()
273279
274- except UiPathDebugQuitError :
280+ except ( UiPathDebugQuitError ) :
275281 raise
276- except Exception as e :
282+
283+ except UiPathResumeTriggerPendingException as e :
284+ # trigger still pending
277285 await self .debug_bridge .emit_state_update (
278286 UiPathRuntimeStateEvent (
279287 node_name = "<polling>" ,
@@ -284,7 +292,7 @@ async def _poll_trigger(
284292 )
285293 )
286294
287- await self ._wait_with_quit_check ()
295+ await self ._wait_with_quit_check ()
288296
289297 async def _wait_with_quit_check (self ) -> None :
290298 """Wait for specified seconds, but allow quit command to interrupt.
0 commit comments