From e499ff6185b8f7a87de3dd4fd81f34f70fd2f9c0 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 21 Dec 2018 01:28:28 -0800 Subject: When url fetch fails with http error, report it instead of just 500 --- server.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'server.py') diff --git a/server.py b/server.py index fc9a731..34f465f 100644 --- a/server.py +++ b/server.py @@ -119,6 +119,10 @@ def site_dispatch(env, start_response): start_response('404 Not Found', ()) yield str(e).encode('utf-8') + except urllib.error.HTTPError as e: + start_response(str(e.code) + ' ' + e.reason, ()) + yield b'While fetching url, the following error occured:\n' + str(e).encode('utf-8') + except socket.error as e: start_response('502 Bad Gateway', ()) print(str(e)) -- cgit v1.2.3