Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Improve tracebacks on exceptions
Browse files Browse the repository at this point in the history
Use failure.Failure to recover our failure, which will give us a useful
stacktrace, unlike the rethrown exception.
  • Loading branch information
richvdh committed Nov 27, 2017
1 parent 79eba87 commit 6be01f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
)

from twisted.internet import defer
from twisted.python import failure
from twisted.web import server, resource
from twisted.web.server import NOT_DONE_YET
from twisted.web.util import redirectTo
Expand Down Expand Up @@ -131,12 +132,17 @@ def wrapped_request_handler(self, request):
version_string=self.version_string,
)
except Exception:
logger.exception(
"Failed handle request %s.%s on %r: %r",
# failure.Failure() fishes the original Failure out
# 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.__name__,
self,
request
request,
f.getTraceback().rstrip(),
)
respond_with_json(
request,
Expand Down

0 comments on commit 6be01f5

Please sign in to comment.