From f4d4044a0441e64908c279d054e36f3449235031 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 1 Jul 2020 00:11:39 +0100 Subject: [PATCH] Implement `AbortHandlerChain` exception for aborting future handlers --- houdini/handlers/__init__.py | 4 ++++ houdini/spheniscidae.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/houdini/handlers/__init__.py b/houdini/handlers/__init__.py index a0645ba..8fa0626 100644 --- a/houdini/handlers/__init__.py +++ b/houdini/handlers/__init__.py @@ -13,6 +13,10 @@ class AuthorityError(Exception): """Raised when a packet is received but user has not yet authenticated""" +class AbortHandlerChain(Exception): + """Exception raised when handler wants to abort the rest of the handler chain""" + + class _Packet: __slots__ = ['id'] diff --git a/houdini/spheniscidae.py b/houdini/spheniscidae.py index 97d26c0..2e2240c 100644 --- a/houdini/spheniscidae.py +++ b/houdini/spheniscidae.py @@ -4,7 +4,7 @@ from xml.etree.cElementTree import Element, SubElement, tostring import defusedxml.cElementTree as Et from houdini.constants import ClientType -from houdini.handlers import AuthorityError, XMLPacket, XTPacket +from houdini.handlers import AuthorityError, AbortHandlerChain, XMLPacket, XTPacket class Spheniscidae: @@ -161,6 +161,8 @@ class Spheniscidae: await self.__handle_xt_data(data) except AuthorityError: self.logger.debug(f'{self} tried to send game packet before authentication') + except AbortHandlerChain as e: + self.logger.info(f'Handler chain aborted: {str(e)}') async def run(self): await self._client_connected()