From e74e93f85722f2a4cdc59c9b4cbc0bb88397d2aa Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 13 Jun 2021 18:01:49 -0400 Subject: [PATCH] Add a specially handled `ContextCancelled` error --- tractor/_exceptions.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tractor/_exceptions.py b/tractor/_exceptions.py index 3d20200..3751dad 100644 --- a/tractor/_exceptions.py +++ b/tractor/_exceptions.py @@ -1,7 +1,7 @@ """ Our classy exception set. """ -from typing import Dict, Any, Optional, Type +from typing import Dict, Any, Optional import importlib import builtins import traceback @@ -18,7 +18,7 @@ class RemoteActorError(Exception): def __init__( self, message: str, - suberror_type: Optional[Type[BaseException]] = None, + suberror_type: Optional[Exception] = None, **msgdata ) -> None: @@ -37,10 +37,6 @@ class InternalActorError(RemoteActorError): """ -class TransportClosed(trio.ClosedResourceError): - "Underlying channel transport was closed prior to use" - - class ContextCancelled(RemoteActorError): "Inter-actor task context cancelled itself on the callee side." @@ -70,22 +66,19 @@ def pack_error(exc: BaseException) -> Dict[str, Any]: def unpack_error( - msg: Dict[str, Any], chan=None, err_type=RemoteActorError - ) -> Exception: """Unpack an 'error' message from the wire into a local ``RemoteActorError``. - """ error = msg['error'] tb_str = error.get('tb_str', '') message = f"{chan.uid}\n" + tb_str type_name = error['type_str'] - suberror_type: Type[BaseException] = Exception + suberror_type = Exception if type_name == 'ContextCancelled': err_type = ContextCancelled