Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate exceptions from a message handler #3

Open
saaj opened this issue Jun 5, 2015 · 0 comments
Open

Propagate exceptions from a message handler #3

saaj opened this issue Jun 5, 2015 · 0 comments

Comments

@saaj
Copy link
Contributor

saaj commented Jun 5, 2015

BaseActor._task should call set_exception on the Future of QueryMessage when message handler raises. It can look like this:

    @asyncio.coroutine
    def _task(self):
        message = yield from self._inbox.get()
        try:
            handler  = self._handlers[type(message)]
            is_query = isinstance(message, QueryMessage)
            try:
                response = yield from handler(message)
            except Exception as ex:
                if is_query:
                    message.result.set_exception(ex)
            else:
                if is_query:
                    message.result.set_result(response)
        except KeyError as ex:
            raise HandlerNotFoundError(type(message)) from ex

What I'm not sure about is whether plain message handler's exception should be re-risen, eaten or maybe a warning should be emitted.

saaj added a commit to saaj/cleveland that referenced this issue Jun 8, 2015
biesnecker added a commit that referenced this issue Dec 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant