From ff31ec9f2fb98895d24dd7d472c1cacccc034d9d Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Sun, 8 May 2022 21:11:43 +0100 Subject: [PATCH 1/7] #16 use the request path in the exception --- adafruit_wsgi/wsgi_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index a9e78ae..73c4d07 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -71,7 +71,7 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): except (ValueError, TypeError) as err: raise RuntimeError( "Proper HTTP response return not given for request handler '{}'".format( - route["func"].__name__ + request.path ) ) from err start_response(status, headers) From d272883ef67ab53f78cc02faff0b187646e2e16c Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Wed, 18 May 2022 16:36:54 +0100 Subject: [PATCH 2/7] Change the exception wording to match the returned item. --- adafruit_wsgi/wsgi_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index 73c4d07..1d5503b 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -70,7 +70,7 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): status, headers, resp_data = route["func"](request, *args) except (ValueError, TypeError) as err: raise RuntimeError( - "Proper HTTP response return not given for request handler '{}'".format( + "Proper HTTP response return not given for request path '{}'".format( request.path ) ) from err From 09cbb07cc73eee3d242e74ebc6d16f5827619501 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Wed, 18 May 2022 16:38:01 +0100 Subject: [PATCH 3/7] Request handler from path makes more sense. --- adafruit_wsgi/wsgi_app.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index 1d5503b..bf4ef20 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -70,9 +70,7 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): status, headers, resp_data = route["func"](request, *args) except (ValueError, TypeError) as err: raise RuntimeError( - "Proper HTTP response return not given for request path '{}'".format( - request.path - ) + f"Proper HTTP response return not given for request handler for path '{request.path}'" ) from err start_response(status, headers) return resp_data From 20507619f815e928bfa36e20d41a4e30fcac40ad Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Wed, 18 May 2022 16:59:09 +0100 Subject: [PATCH 4/7] Pylint fix. --- adafruit_wsgi/wsgi_app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index bf4ef20..1584605 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -70,7 +70,8 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): status, headers, resp_data = route["func"](request, *args) except (ValueError, TypeError) as err: raise RuntimeError( - f"Proper HTTP response return not given for request handler for path '{request.path}'" + f"Proper HTTP response return not given for request handler for path \ + '{request.path}'" ) from err start_response(status, headers) return resp_data From d91ba3ccc4cadca6593c0953b10612f287d59259 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Fri, 20 May 2022 11:54:28 +0100 Subject: [PATCH 5/7] Sort out the unwanted indents. Also make the message a little less wordy. --- adafruit_wsgi/wsgi_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index 1584605..4f1fa32 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -70,8 +70,8 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): status, headers, resp_data = route["func"](request, *args) except (ValueError, TypeError) as err: raise RuntimeError( - f"Proper HTTP response return not given for request handler for path \ - '{request.path}'" + "Proper HTTP response not returned by request handler for path " + + "'{request.path}'" ) from err start_response(status, headers) return resp_data From 9b2275ce0b18aa285627f5d74c2e6b13dc0196b7 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Fri, 20 May 2022 11:58:33 +0100 Subject: [PATCH 6/7] Format --- adafruit_wsgi/wsgi_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index 4f1fa32..f6795d5 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -71,7 +71,7 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): except (ValueError, TypeError) as err: raise RuntimeError( "Proper HTTP response not returned by request handler for path " - + "'{request.path}'" + + "'{request.path}'" ) from err start_response(status, headers) return resp_data From fb6cb46db3006a1a312e99ae1f0b69923d625b6d Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Sat, 21 May 2022 13:04:12 +0100 Subject: [PATCH 7/7] Facepalm. Fix this. --- adafruit_wsgi/wsgi_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_wsgi/wsgi_app.py b/adafruit_wsgi/wsgi_app.py index f6795d5..95421a5 100644 --- a/adafruit_wsgi/wsgi_app.py +++ b/adafruit_wsgi/wsgi_app.py @@ -71,7 +71,7 @@ def __call__(self, environ: Dict[str, str], start_response: Callable): except (ValueError, TypeError) as err: raise RuntimeError( "Proper HTTP response not returned by request handler for path " - + "'{request.path}'" + + f"'{request.path}'" ) from err start_response(status, headers) return resp_data