Skip to content

Raise error on HTTP Error and fix json w/ no path #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2020

Conversation

makermelissa
Copy link
Collaborator

Fixes #92. I also am raising an error for HTTP errors. The reason for this is it was returning None and later in the code giving an unrelated confusing message.

The bulk of this PR is if no Path is defined, values was an empty list and code that was written such as the weather station expected the JSON as a string to be returned. I realize loading json and using json.dumps() uses more memory, but rather than only grabbing r.text if there was no path, I didn't want to break it if the json_transform was provided which expects a dict. However, it won't load json until it actually has to so it only does it for the single edge case.

@makermelissa makermelissa requested a review from a team November 5, 2020 21:36
@makermelissa
Copy link
Collaborator Author

Also, the reason it was causing a problem now is because in this condition it would read r.json() followed by r.text. This fixes it.

@joelguth
Copy link

joelguth commented Nov 6, 2020

Excellent, this appears to have fixed the issues I was facing with the weather station. Thank you!

@makermelissa
Copy link
Collaborator Author

Thanks for testing @joelguth.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I like the new HttpError. It makes things clearer. :-)

@tannewt tannewt merged commit 2ac9269 into adafruit:master Nov 6, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 7, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.2.2 from 5.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#60 from adafruit/fix-super-call

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.5.3 from 3.5.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#114 from tannewt/esp32spi_fixes

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH to 5.1.5 from 5.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3DH#63 from adafruit/ladyada-patch-3

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.6.2 from 3.6.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#93 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.9.3 from 2.9.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#96 from FoamyGuy/add_matrixportal_example

Updating https://github.com/adafruit/Adafruit_CircuitPython_MatrixPortal to 1.9.0 from 1.8.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_MatrixPortal#38 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_miniesptool to 0.2.5 from 0.2.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_miniesptool#23 from adafruit/nina-fw-1.7.1-updates

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.7.5 from 1.7.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#50 from tannewt/better_error_handling
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#49 from adafruit/no-https-wifitest
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#45 from tannewt/fix_close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If no JSON Path is provided it gets confused and errors
3 participants