Skip to content

Commit

Permalink
Change to catch ValueError and TypeError
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Halbert <[email protected]>
  • Loading branch information
tekktrik and dhalbert authored Mar 16, 2022
1 parent 0bd806e commit a317a99
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions adafruit_wsgi/wsgi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,12 @@ def __call__(self, environ: Dict[str, str], start_response: Callable):

if match:
args, route = match
response_params = route["func"](request, *args)
if (
not isinstance(response_params, (list, tuple))
or len(response_params) != 3
):
try:
status, headers, resp_data = route["func"](request, *args)
except ValueError, TypeError:
raise RuntimeError(
"Proper HTTP response return not given for request handler '{}'".format(
route["func"].__name__
)
)
status, headers, resp_data = response_params
start_response(status, headers)
return resp_data

Expand Down

0 comments on commit a317a99

Please sign in to comment.