Skip to content

Commit c767ac3

Browse files
committed
fix: handle error messages better
1 parent 504bcdf commit c767ac3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

openevsehttp/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,21 @@ async def process_request(
222222
except ValueError:
223223
_LOGGER.warning("Non JSON response: %s", message)
224224

225+
error = await resp.text()
226+
225227
if resp.status == 400:
226228
_LOGGER.error("Error 400: %s", message["msg"])
227229
raise ParseJSONError
228230
if resp.status == 401:
229-
error = await resp.text()
230231
_LOGGER.error("Authentication error: %s", error)
231232
raise AuthenticationError
232233
if resp.status == 404:
233-
_LOGGER.error("%s", message["msg"])
234+
_LOGGER.error("%s", error)
234235
raise UnknownError
235236
if resp.status == 405:
236-
_LOGGER.error("%s", message["msg"])
237+
_LOGGER.error("%s", error)
237238
elif resp.status == 500:
238-
_LOGGER.error("%s", message["msg"])
239+
_LOGGER.error("%s", error)
239240

240241
return message
241242

0 commit comments

Comments
 (0)