From 96a448b02c9dad144b83eec85ba0c80e2e0cd496 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 11 Oct 2023 12:22:50 -1000 Subject: [PATCH] Fix bad except clauses order (#565) --- aioesphomeapi/connection.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aioesphomeapi/connection.py b/aioesphomeapi/connection.py index d0502fa..c73ce4f 100644 --- a/aioesphomeapi/connection.py +++ b/aioesphomeapi/connection.py @@ -304,10 +304,10 @@ class APIConnection: coro = self._loop.sock_connect(self._socket, sockaddr) async with async_timeout.timeout(TCP_CONNECT_TIMEOUT): await coro - except OSError as err: - raise SocketAPIError(f"Error connecting to {sockaddr}: {err}") from err except asyncio.TimeoutError as err: raise SocketAPIError(f"Timeout while connecting to {sockaddr}") from err + except OSError as err: + raise SocketAPIError(f"Error connecting to {sockaddr}: {err}") from err _LOGGER.debug( "%s: Opened socket to %s:%s (%s)", @@ -350,10 +350,10 @@ class APIConnection: self._set_connection_state(ConnectionState.SOCKET_OPENED) try: await fh.perform_handshake(HANDSHAKE_TIMEOUT) - except OSError as err: - raise HandshakeAPIError(f"Handshake failed: {err}") from err except asyncio.TimeoutError as err: raise TimeoutAPIError("Handshake timed out") from err + except OSError as err: + raise HandshakeAPIError(f"Handshake failed: {err}") from err async def _connect_hello(self) -> None: """Step 4 in connect process: send hello and get api version."""