diff --git a/tractor/_exceptions.py b/tractor/_exceptions.py index 418accc3..3c469222 100644 --- a/tractor/_exceptions.py +++ b/tractor/_exceptions.py @@ -46,6 +46,7 @@ from msgspec import ( from tractor._state import current_actor from tractor.log import get_logger from tractor.msg import ( + Aid, Error, PayloadMsg, MsgType, @@ -479,9 +480,10 @@ class RemoteActorError(Exception): @property def relay_uid(self) -> tuple[str, str]|None: - return tuple( - self._ipc_msg.relay_path[-1] - ) + if msg := self._ipc_msg: + return tuple( + msg.relay_path[-1] + ) @property def src_uid(self) -> tuple[str, str]|None: @@ -521,7 +523,8 @@ class RemoteActorError(Exception): for key in fields: if ( key == 'relay_uid' - and not self.is_inception() + and + not self.is_inception() ): continue @@ -534,6 +537,13 @@ class RemoteActorError(Exception): None, ) ) + if ( + key == 'canceller' + and + isinstance(val, Aid) + ): + val: str = val.reprol(sin_uuid=False) + # TODO: for `.relay_path` on multiline? # if not isinstance(val, str): # val_str = pformat(val) @@ -623,25 +633,32 @@ class RemoteActorError(Exception): # IFF there is an embedded traceback-str we always # draw the ascii-box around it. body: str = '' - if tb_str := self.tb_str: - fields: str = self._mk_fields_str( - _body_fields - + - self.extra_body_fields, - ) - from tractor.devx import ( - pformat_boxed_tb, - ) - body: str = pformat_boxed_tb( - tb_str=tb_str, - fields_str=fields, - field_prefix=' |_', - # ^- is so that it's placed like so, - # just after Aid: + ''' + Return the (maybe) `Actor.aid: Aid` for the requesting-author + of this actorc. + + Emit a warning msg when `.canceller` has not been set. + + See additional relevant notes in + `ContextCancelled.canceller`. + + ''' + value: tuple[str, str]|None + if msg := self._ipc_msg: + value = msg.canceller + else: + value = self._extra_msgdata['canceller'] + + if value: + return value + + log.warning( + 'IPC Context cancelled without a requesting actor?\n' + 'Maybe the IPC transport ended abruptly?\n\n' + f'{self}' + ) + + class MsgTypeError( RemoteActorError, ):