diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf205aa..e8adc7d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,7 +54,7 @@ repos: hooks: - id: codespell - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/poetry.lock b/poetry.lock index b540407..c36c07b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -640,4 +640,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "871166d66109989a7bc1632dcca0e8ebb32dab7f3f8ff0fbf9ff4c5541b4c826" +content-hash = "2006edcbaabd3c88cf3a0913bac315153e9ac2497976b35de0edafcd21cb4be7" diff --git a/src/anova_wifi/websocket_handler.py b/src/anova_wifi/websocket_handler.py index f17bd51..2199607 100644 --- a/src/anova_wifi/websocket_handler.py +++ b/src/anova_wifi/websocket_handler.py @@ -3,8 +3,9 @@ import logging from typing import Any -from aiohttp import ClientSession, ClientWebSocketResponse +from aiohttp import ClientSession, ClientWebSocketResponse, WebSocketError +from . import WebsocketFailure from .web_socket_containers import ( AnovaCommand, APCWifiDevice, @@ -24,7 +25,10 @@ def __init__(self, firebase_jwt: str, jwt: str, session: ClientSession): self.ws: ClientWebSocketResponse | None = None async def connect(self) -> None: - self.ws = await self.session.ws_connect(self.url) + try: + self.ws = await self.session.ws_connect(self.url) + except WebSocketError as ex: + raise WebsocketFailure("Failed to connect to the websocket") from ex asyncio.ensure_future(self.message_listener()) async def disconnect(self) -> None: