Skip to content

Commit

Permalink
feat: websocket error raising
Browse files Browse the repository at this point in the history
  • Loading branch information
Lash-L committed Apr 25, 2024
2 parents 5611851 + cea2548 commit 5f020db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/anova_wifi/websocket_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down

0 comments on commit 5f020db

Please sign in to comment.