Improve otbr error handling (#124277)

pull/124280/head
Erik Montnemery 2024-08-20 10:33:02 +02:00 committed by GitHub
parent e81aa1cdb2
commit d3deaa6a82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -168,7 +168,11 @@ class OTBRConfigFlow(ConfigFlow, domain=DOMAIN):
try:
await self._connect_and_set_dataset(url)
except python_otbr_api.OTBRError as exc:
except (
python_otbr_api.OTBRError,
aiohttp.ClientError,
TimeoutError,
) as exc:
_LOGGER.warning("Failed to communicate with OTBR@%s: %s", url, exc)
return self.async_abort(reason="unknown")

View File

@ -9,6 +9,7 @@ import logging
import random
from typing import Any, Concatenate, cast
import aiohttp
import python_otbr_api
from python_otbr_api import PENDING_DATASET_DELAY_TIMER, tlv_parser
from python_otbr_api.pskc import compute_pskc
@ -67,7 +68,7 @@ def _handle_otbr_error[**_P, _R](
async def _func(self: OTBRData, *args: _P.args, **kwargs: _P.kwargs) -> _R:
try:
return await func(self, *args, **kwargs)
except python_otbr_api.OTBRError as exc:
except (python_otbr_api.OTBRError, aiohttp.ClientError, TimeoutError) as exc:
raise HomeAssistantError("Failed to call OTBR API") from exc
return _func