nkgilley / python-ecobee-api

Python API for controlling Ecobee Thermostats
MIT License
44 stars 40 forks source link

Handle bad JSON payloads better #49

Closed jjlawren closed 4 years ago

jjlawren commented 4 years ago

Another followup to #47 and #48. This will ensure that we handle bad JSON payloads a bit more cleanly:

  1. Don't attempt to decode JSON immediately and print the .text to be safe.
  2. Check the .json() contents immediately after an HTTP error code is detected.
  3. Safely check the contents of the JSON payload dictionary.

If both this PR and #48 are considered mergeable, perhaps merging this PR before #48 would make a cleaner release process.