Skip to content

Commit 7fdf5c2

Browse files
committed
Increase scope of _request() exceptions
As a solution for #187
1 parent 640c7f4 commit 7fdf5c2

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

plugwise/helper.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77
import datetime as dt
88

99
# This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts)
10-
from aiohttp import (
11-
BasicAuth,
12-
ClientResponse,
13-
ClientSession,
14-
ClientTimeout,
15-
ServerTimeoutError,
16-
)
10+
from aiohttp import BasicAuth, ClientError, ClientResponse, ClientSession, ClientTimeout
1711
from dateutil.parser import parse
1812
from defusedxml import ElementTree as etree
1913
from munch import Munch
@@ -54,9 +48,9 @@
5448
ThermoLoc,
5549
)
5650
from .exceptions import (
57-
DeviceTimeoutError,
5851
InvalidAuthentication,
5952
InvalidXMLError,
53+
PlugwiseException,
6054
ResponseError,
6155
)
6256
from .util import (
@@ -266,12 +260,12 @@ async def _request(
266260
data=data,
267261
auth=self._auth,
268262
)
269-
except ServerTimeoutError:
263+
except ClientError as err: # ClientError is an ancestor class of ServerTimeroutError
270264
if retry < 1:
271-
LOGGER.error("Timed out sending %s command to Plugwise", command)
272-
raise DeviceTimeoutError(
273-
"Plugwise timeout error, check log for more info."
274-
)
265+
LOGGER.error("failed sending %s %s to Plugwise", method, command)
266+
raise PlugwiseException(
267+
"Plugwise connection error, check log for more info."
268+
) from err
275269
return await self._request(command, retry - 1)
276270

277271
return await self._request_validate(resp, method)

0 commit comments

Comments
 (0)