From a317a996688d733920579d8318ec3dbf26bc597f Mon Sep 17 00:00:00 2001 From: tekktrik <89490472+tekktrik@users.noreply.github.com> Date: Tue, 15 Mar 2022 21:44:47 -0400 Subject: [PATCH] Change to catch ValueError and TypeError Co-authored-by: Dan Halbert --- adafruit_wsgi/wsgi_app.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index e213a95..c1cc67c 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -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