aboutsummaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-12-21 01:28:28 -0800
committerJames Taylor <user234683@users.noreply.github.com>2018-12-21 01:28:28 -0800
commite499ff6185b8f7a87de3dd4fd81f34f70fd2f9c0 (patch)
treed7bdee5e254d6d683b239aedabda06166dc96384 /server.py
parent30ed068c3368860fb3fc7fcbc9a1d92365955a7f (diff)
downloadyt-local-e499ff6185b8f7a87de3dd4fd81f34f70fd2f9c0.tar.lz
yt-local-e499ff6185b8f7a87de3dd4fd81f34f70fd2f9c0.tar.xz
yt-local-e499ff6185b8f7a87de3dd4fd81f34f70fd2f9c0.zip
When url fetch fails with http error, report it instead of just 500
Diffstat (limited to 'server.py')
-rw-r--r--server.py4
1 files changed, 4 insertions, 0 deletions
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))