Show error code and text in browser.

pull/7/head
Ferry Boender 10 years ago
parent 20010fb0a4
commit 6723038209
  1. 5
      src/webapp.py

@ -207,12 +207,17 @@ class WebAppHandler(BaseHTTPRequestHandler):
raise HTTPError(404, "Not found") raise HTTPError(404, "Not found")
method_cb(**params) method_cb(**params)
except HTTPError, e: except HTTPError, e:
# HTTP erors are generally thrown by the webapp on purpose. Send
# error to the browser.
if e.status_code not in (401, ): if e.status_code not in (401, ):
self.scriptform.log.exception(e) self.scriptform.log.exception(e)
self.send_response(e.status_code) self.send_response(e.status_code)
for header_k, header_v in e.headers.items(): for header_k, header_v in e.headers.items():
self.send_header(header_k, header_v) self.send_header(header_k, header_v)
self.end_headers() self.end_headers()
self.wfile.write("Error {}: {}".format(e.status_code,
e.msg))
self.wfile.flush()
return False return False
except Exception, e: except Exception, e:
self.scriptform.log.exception(e) self.scriptform.log.exception(e)

Loading…
Cancel
Save