diff --git a/novus/api/gateway/gateway.py b/novus/api/gateway/gateway.py index f623ce43..24599956 100644 --- a/novus/api/gateway/gateway.py +++ b/novus/api/gateway/gateway.py @@ -34,7 +34,12 @@ from ...enums import GatewayOpcode from ...flags import Intents from ...utils import MISSING -from .._errors import GatewayClose, GatewayClosed, GatewayException +from .._errors import ( + GatewayAuthenticationFailed, + GatewayClose, + GatewayClosed, + GatewayException, +) from .._route import Route from .dispatch import GatewayDispatch @@ -317,6 +322,9 @@ async def messages( self.running_tasks.add(t) t.add_done_callback(self.running_tasks.discard) return + except GatewayAuthenticationFailed: + log.info("[%s] Gateway authentication failed, closing with error code", self.shard_id) + exit(1) except GatewayException as e: log.debug("[%s] Generic gateway exception %s", self.shard_id, e, exc_info=e) t = asyncio.create_task(self.reconnect(resume=e.reconnect))