Skip to content

Commit a317a99

Browse files
tekktrikdhalbert
andauthored
Change to catch ValueError and TypeError
Co-authored-by: Dan Halbert <halbert@halwitz.org>
1 parent 0bd806e commit a317a99

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

adafruit_wsgi/wsgi_app.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,12 @@ def __call__(self, environ: Dict[str, str], start_response: Callable):
6666

6767
if match:
6868
args, route = match
69-
response_params = route["func"](request, *args)
70-
if (
71-
not isinstance(response_params, (list, tuple))
72-
or len(response_params) != 3
73-
):
69+
try:
70+
status, headers, resp_data = route["func"](request, *args)
71+
except ValueError, TypeError:
7472
raise RuntimeError(
7573
"Proper HTTP response return not given for request handler '{}'".format(
7674
route["func"].__name__
77-
)
78-
)
79-
status, headers, resp_data = response_params
8075
start_response(status, headers)
8176
return resp_data
8277

0 commit comments

Comments
 (0)