forked from goodboy/tractor
Pass `boxed_type` from `_mk_msg_type_err()`
Such that we're boxing the interchanged lib's specific error `msgspec.ValidationError` in this case) type much like how a `ContextCancelled[trio.Cancelled]` is composed; allows for seemless multi-backend-codec support later as well B) Pass `ctx.maybe_raise(from_src_exc=src_err)` where needed in a couple spots; as `None` in the send-side `Started` MTE case to avoid showing the `._scope1.cancel_called` result in the traceback from the `.open_context()` child-sync phase.runtime_to_msgspec
parent
bbb4d4e52c
commit
993281882b
|
@ -518,7 +518,6 @@ class RemoteActorError(Exception):
|
||||||
def pformat(
|
def pformat(
|
||||||
self,
|
self,
|
||||||
with_type_header: bool = True,
|
with_type_header: bool = True,
|
||||||
# with_ascii_box: bool = True,
|
|
||||||
|
|
||||||
) -> str:
|
) -> str:
|
||||||
'''
|
'''
|
||||||
|
@ -885,9 +884,9 @@ class MsgTypeError(
|
||||||
extra_msgdata['_bad_msg'] = bad_msg
|
extra_msgdata['_bad_msg'] = bad_msg
|
||||||
extra_msgdata['cid'] = bad_msg.cid
|
extra_msgdata['cid'] = bad_msg.cid
|
||||||
|
|
||||||
|
extra_msgdata.setdefault('boxed_type', cls)
|
||||||
return cls(
|
return cls(
|
||||||
message=message,
|
message=message,
|
||||||
boxed_type=cls,
|
|
||||||
**extra_msgdata,
|
**extra_msgdata,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1111,7 +1110,7 @@ def is_multi_cancelled(
|
||||||
def _raise_from_unexpected_msg(
|
def _raise_from_unexpected_msg(
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
msg: MsgType,
|
msg: MsgType,
|
||||||
src_err: AttributeError,
|
src_err: Exception,
|
||||||
log: StackLevelAdapter, # caller specific `log` obj
|
log: StackLevelAdapter, # caller specific `log` obj
|
||||||
|
|
||||||
expect_msg: Type[MsgType],
|
expect_msg: Type[MsgType],
|
||||||
|
@ -1212,7 +1211,7 @@ def _raise_from_unexpected_msg(
|
||||||
# in case there already is some underlying remote error
|
# in case there already is some underlying remote error
|
||||||
# that arrived which is probably the source of this stream
|
# that arrived which is probably the source of this stream
|
||||||
# closure
|
# closure
|
||||||
ctx.maybe_raise()
|
ctx.maybe_raise(from_src_exc=src_err)
|
||||||
raise eoc from src_err
|
raise eoc from src_err
|
||||||
|
|
||||||
# TODO: our own transport/IPC-broke error subtype?
|
# TODO: our own transport/IPC-broke error subtype?
|
||||||
|
@ -1361,6 +1360,7 @@ def _mk_msg_type_err(
|
||||||
message=message,
|
message=message,
|
||||||
bad_msg=bad_msg,
|
bad_msg=bad_msg,
|
||||||
bad_msg_as_dict=msg_dict,
|
bad_msg_as_dict=msg_dict,
|
||||||
|
boxed_type=type(src_validation_error),
|
||||||
|
|
||||||
# NOTE: for pld-spec MTEs we set the `._ipc_msg` manually:
|
# NOTE: for pld-spec MTEs we set the `._ipc_msg` manually:
|
||||||
# - for the send-side `.started()` pld-validate
|
# - for the send-side `.started()` pld-validate
|
||||||
|
|
|
@ -233,6 +233,7 @@ class MsgStream(trio.abc.Channel):
|
||||||
# ctx: Context = self._ctx
|
# ctx: Context = self._ctx
|
||||||
ctx.maybe_raise(
|
ctx.maybe_raise(
|
||||||
raise_ctxc_from_self_call=True,
|
raise_ctxc_from_self_call=True,
|
||||||
|
from_src_exc=src_err,
|
||||||
)
|
)
|
||||||
|
|
||||||
# propagate any error but hide low-level frame details
|
# propagate any error but hide low-level frame details
|
||||||
|
|
Loading…
Reference in New Issue