Skip to content

Clearer error raised when function gives improper HTTP response return #13

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 5 commits into from
Mar 16, 2022
Merged

Clearer error raised when function gives improper HTTP response return #13

merged 5 commits into from
Mar 16, 2022

Conversation

tekktrik
Copy link
Member

@tekktrik tekktrik commented Mar 9, 2022

Resolves #11 by transforming TypeError into RuntimeError that also references that faulty method/function in question. I do this all the time (-_-"). It will explicitly check for a list or tuple of length 3, which is the expected response for a request handler.

Tested on Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit Pybadge with samd51j19 with AirLift FeatherWing

@tekktrik tekktrik requested a review from a team March 9, 2022 04:09
Explicitly check for list/tuple of length 3
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

What do you think?

@tekktrik
Copy link
Member Author

tekktrik commented Mar 16, 2022

@dhalbert great suggestion, I always forget that multiple exception can be caught. I think that perfectly does what I was trying to do in a more Pythonic way.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks!

@dhalbert
Copy link
Contributor

Ha!

adafruit_wsgi/wsgi_app.py:71:20: E0001: multiple exception types must be parenthesized (<unknown>, line 71) (syntax-error)

@tekktrik
Copy link
Member Author

Haha you caught me as I was fixing it, should be all set now, also uses the from in case that ever gets implemented. My understanding is that it's just ignored right now in CPY.

@dhalbert dhalbert merged commit 980d787 into adafruit:main Mar 16, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 18, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_APDS9960 to 3.1.0 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_APDS9960#42 from bablokb/4upstream
  > Fixed readthedocs build
  > Post-patch cleanup

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS to 4.4.1 from 4.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM6DS#52 from jerryneedell/jerryn_mlc

Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7789 to 1.5.6 from 1.5.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_ST7789#30 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L0X to 3.6.0 from 3.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L0X#35 from whogben/main
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.12.3 from 1.12.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#54 from masgari/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 8.2.2 from 8.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#159 from dhalbert/nus-doc-fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_LYWSD03MMC to 1.0.6 from 1.0.5:
  > Fixed readthedocs build

Updating https://github.com/adafruit/Adafruit_CircuitPython_MagTag to 2.1.8 from 2.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#82 from makermelissa/main
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#81 from makermelissa/main
  > Fixed readthedocs build

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.3.0 from 5.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#106 from dgriswo/subscription_logging

Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.11.1 from 1.11.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#64 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_WSGI to 1.1.9 from 1.1.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_WSGI#13 from tekktrik/dev/clearer-bad-return
  > Fixed readthedocs build
  > Post-patch cleanup
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.

NoneType is not iterable (finish_response)
2 participants