Add a specially handled `ContextCancelled` error
parent
c92fc33b7c
commit
e74e93f857
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue