Skip to content

Commit

Permalink
Filter SSLErrors by code
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Sep 6, 2023
1 parent 82d42e7 commit 8e760ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Re add channel 7 for HmIPW-WRC6
- Reduce log level for exceptions in fetch_paramset_description
- Filter SSLErrors by code

# Version 2023.9.0 (2023-09-03)

Expand Down
9 changes: 8 additions & 1 deletion hahomematic/xml_rpc_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"ping",
)

_SSL_ERROR_CODES: Final[dict[int, str]] = {
errno.ENOEXEC: "EOF occurred in violation of protocol",
}

_NO_CONNECTION_ERROR_CODES: Final[dict[int, str]] = {
errno.ECONNREFUSED: "Connection refused",
errno.ENETUNREACH: "Network is unreachable",
Expand Down Expand Up @@ -99,7 +103,10 @@ async def __async_request(self, *args, **kwargs): # type: ignore[no-untyped-def
raise NoConnection(f"No connection to {self.interface_id}")
except SSLError as sslerr:
message = f"SSLError on {self.interface_id}: {reduce_args(args=sslerr.args)}"
_LOGGER.error(message)
if sslerr.args[0] in _SSL_ERROR_CODES:
_LOGGER.debug(message)
else:
_LOGGER.error(message)
raise NoConnection(message) from sslerr
except OSError as ose:
message = f"OSError on {self.interface_id}: {reduce_args(args=ose.args)}"
Expand Down

0 comments on commit 8e760ae

Please sign in to comment.