mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Improve otbr error handling (#124277)
This commit is contained in:
parent
e81aa1cdb2
commit
d3deaa6a82
@ -168,7 +168,11 @@ class OTBRConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await self._connect_and_set_dataset(url)
|
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)
|
_LOGGER.warning("Failed to communicate with OTBR@%s: %s", url, exc)
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import logging
|
|||||||
import random
|
import random
|
||||||
from typing import Any, Concatenate, cast
|
from typing import Any, Concatenate, cast
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
import python_otbr_api
|
import python_otbr_api
|
||||||
from python_otbr_api import PENDING_DATASET_DELAY_TIMER, tlv_parser
|
from python_otbr_api import PENDING_DATASET_DELAY_TIMER, tlv_parser
|
||||||
from python_otbr_api.pskc import compute_pskc
|
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:
|
async def _func(self: OTBRData, *args: _P.args, **kwargs: _P.kwargs) -> _R:
|
||||||
try:
|
try:
|
||||||
return await func(self, *args, **kwargs)
|
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
|
raise HomeAssistantError("Failed to call OTBR API") from exc
|
||||||
|
|
||||||
return _func
|
return _func
|
||||||
|
Loading…
x
Reference in New Issue
Block a user