Skip to content

Commit 62836a4

Browse files
authored
fix: handle error messages better
2 parents 504bcdf + a3b2c18 commit 62836a4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
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

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
PROJECT_DIR = Path(__file__).parent.resolve()
77
README_FILE = PROJECT_DIR / "README.md"
8-
VERSION = "0.1.32"
8+
VERSION = "0.1.33"
99

1010
setup(
1111
name="python-openevse-http",

0 commit comments

Comments
 (0)