Skip to content

Commit 1d3708e

Browse files
committed
Move error-messages into raise
1 parent 417f92c commit 1d3708e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

plugwise/helper.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,18 @@ async def _request_validate(self, resp: ClientResponse, method: str) -> etree:
227227
return
228228

229229
if resp.status == 401:
230-
raise InvalidAuthentication
230+
raise InvalidAuthentication(
231+
"Invalid login, please retry with the correct credentials."
232+
)
231233

232234
if not (result := await resp.text()) or "<error>" in result:
233-
LOGGER.error("Smile response empty or error in %s", result)
234-
raise ResponseError
235+
raise ResponseError(f"Smile response empty or error in {result}.")
235236

236237
try:
237238
# Encode to ensure utf8 parsing
238239
xml = etree.XML(escape_illegal_xml_characters(result).encode())
239240
except etree.ParseError:
240-
LOGGER.error("Smile returns invalid XML for %s", self._endpoint)
241-
raise InvalidXMLError
241+
raise InvalidXMLError(f"Smile returns invalid XML for {self._endpoint}.")
242242

243243
return xml
244244

@@ -271,8 +271,9 @@ async def _request(
271271
)
272272
except ServerTimeoutError:
273273
if retry < 1:
274-
LOGGER.error("Timed out sending %s command to Plugwise", command)
275-
raise DeviceTimeoutError
274+
raise DeviceTimeoutError(
275+
f"Timed out sending {command} command to Plugwise"
276+
)
276277
return await self._request(command, retry - 1)
277278

278279
return await self._request_validate(resp, method)

0 commit comments

Comments
 (0)