Catch ssl errors in rest (#91074)

* catch ssl.SSLError

* add test

* fail setup on ssl error

* adjust tests
This commit is contained in:
Michael 2023-04-12 06:51:41 +02:00 committed by GitHub
parent 2c9e9d0fde
commit 0916701a0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 117 additions and 0 deletions

View file

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
import ssl
from xml.parsers.expat import ExpatError
from jsonpath import jsonpath
@ -67,6 +68,13 @@ async def async_setup_platform(
if rest.data is None:
if rest.last_exception:
if isinstance(rest.last_exception, ssl.SSLError):
_LOGGER.error(
"Error connecting %s failed with %s",
conf[CONF_RESOURCE],
rest.last_exception,
)
return
raise PlatformNotReady from rest.last_exception
raise PlatformNotReady