Skip to content

Commit

Permalink
Add an explicit messaging error for reporting an illegal context tran…
Browse files Browse the repository at this point in the history
…saction
  • Loading branch information
goodboy committed Dec 15, 2021
1 parent 5b59375 commit fff8081
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tractor/_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from functools import partial
from dataclasses import dataclass
from pprint import pformat
import warnings

import trio
Expand Down Expand Up @@ -85,6 +86,9 @@ def _unwrap_msg(
assert msg.get('cid'), "Received internal error at portal?"
raise unpack_error(msg, channel)

class MessagingError(Exception):
'Some kind of unexpected SC messaging dialog issue'


class Portal:
'''
Expand Down Expand Up @@ -408,8 +412,6 @@ async def open_context(
raise TypeError(
f'{func} must be an async generator function!')

__tracebackhide__ = True

fn_mod_path, fn_name = func_deats(func)

ctx = await self.actor.start_remote_task(
Expand All @@ -435,7 +437,10 @@ async def open_context(
# raise kerr from unpack_error(msg, self.channel)
raise unpack_error(msg, self.channel) from None
else:
raise
raise MessagingError(
f'Context for {ctx.cid} was expecting a `started` message'
f' but received a non-error msg:\n{pformat(msg)}'
)

_err: Optional[BaseException] = None
ctx._portal = self
Expand Down

0 comments on commit fff8081

Please sign in to comment.