Change logging in handle_error.

This commit is contained in:
Konstantin Kapustin 2012-03-27 17:15:49 +04:00 committed by Randall Leeds
parent 4a01269871
commit ac223ae639

View File

@ -126,12 +126,6 @@ class Worker(object):
sys.exit(0)
def handle_error(self, client, exc):
self.log.exception("Error handling request")
status_int = 500
reason = "Internal Server Error"
mesg = ""
if isinstance(exc, (InvalidRequestLine, InvalidRequestMethod,
InvalidHTTPVersion, InvalidHeader, InvalidHeaderName,)):
@ -151,6 +145,18 @@ class Worker(object):
elif isinstance(exc, LimitRequestHeaders):
mesg = "<p>Error parsing headers: '%s'</p>" % str(exc)
self.log.debug("Invalid request from ip={ip}: {error}"\
"".format(ip=client.getpeername()[0],
error=repr(exc),
)
)
else:
self.log.exception("Error handling request")
status_int = 500
reason = "Internal Server Error"
mesg = ""
if self.debug:
tb = traceback.format_exc()
mesg += "<h2>Traceback:</h2>\n<pre>%s</pre>" % tb