adafruit / Adafruit_CircuitPython_WSGI

WSGI library for simple web servers
MIT License
20 stars 18 forks source link

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

Closed tekktrik closed 2 years ago

tekktrik commented 2 years ago

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 commented 2 years ago

@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.

dhalbert commented 2 years ago

Ha!

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

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.