Skip to content
Snippets Groups Projects
Commit 6be01f59 authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Improve tracebacks on exceptions

Use failure.Failure to recover our failure, which will give us a useful
stacktrace, unlike the rethrown exception.
parent 79eba878
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ from canonicaljson import ( ...@@ -28,6 +28,7 @@ from canonicaljson import (
) )
from twisted.internet import defer from twisted.internet import defer
from twisted.python import failure
from twisted.web import server, resource from twisted.web import server, resource
from twisted.web.server import NOT_DONE_YET from twisted.web.server import NOT_DONE_YET
from twisted.web.util import redirectTo from twisted.web.util import redirectTo
...@@ -131,12 +132,17 @@ def wrap_request_handler(request_handler, include_metrics=False): ...@@ -131,12 +132,17 @@ def wrap_request_handler(request_handler, include_metrics=False):
version_string=self.version_string, version_string=self.version_string,
) )
except Exception: except Exception:
logger.exception( # failure.Failure() fishes the original Failure out
"Failed handle request %s.%s on %r: %r", # of our stack, and thus gives us a sensible stack
# trace.
f = failure.Failure()
logger.error(
"Failed handle request %s.%s on %r: %r: %s",
request_handler.__module__, request_handler.__module__,
request_handler.__name__, request_handler.__name__,
self, self,
request request,
f.getTraceback().rstrip(),
) )
respond_with_json( respond_with_json(
request, request,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment