Skip to content

Handle HTTP errors and content type better #88

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 1 commit into from
Oct 12, 2020

Conversation

makermelissa
Copy link
Collaborator

Fixes #37.

Summary of changes:

Tested on CircuitPython 6 Beta 2 with latest bundle.

@makermelissa makermelissa requested review from a team and removed request for a team October 9, 2020 17:17
@makermelissa makermelissa changed the title Handle HTTP errors and content type better WIP: Handle HTTP errors and content type better Oct 9, 2020
@makermelissa makermelissa requested a review from a team October 9, 2020 22:39
@makermelissa makermelissa changed the title WIP: Handle HTTP errors and content type better Handle HTTP errors and content type better Oct 9, 2020
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

I tested these changes with PyPortal Adafruit CircuitPython 6.0.0-beta.2 on 2020-10-05; Adafruit PyPortal with samd51j20

I tested text with the simpletest script in examples, and json with the quotes script. I also checked a few HTTP errors using a local web server, those are printing nicely.

I have been unsuccessful testing the images so far, but I think I may not be understanding how to use it properly. I'm going to try poking around some other projects later today to see if I can figure that out.

@makermelissa
Copy link
Collaborator Author

makermelissa commented Oct 12, 2020

Thanks @FoamyGuy. Yeah, images isn't working with version 1.7.x of Requests at the moment. I have an issue open for that at adafruit/Adafruit_CircuitPython_Requests#41. Also, this has a temporary fix in place for adafruit/Adafruit_CircuitPython_Requests#40, but after it's fixed, I may go back and undo the change. However, this does accomplish the original goal of handling errors and content type better.

@makermelissa makermelissa merged commit 2271503 into adafruit:master Oct 12, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 13, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.5.0 from 3.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#88 from makermelissa/http-errors
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#87 from makermelissa/content-headers
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#80 from virgilvox/patch-1
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.

Improve error handling for HTTP response errors and exception handling for JSON parse parsing in fetch()
2 participants