Log original exception in debug mode.

Sanic is collecting the information of original exceptions but does
not print it on console. Because it is very useful to debug user code,
it is better to be logged as debug logs.
This commit is contained in:
Jeong YunWon 2016-12-28 18:17:22 +09:00
parent 73a57e1105
commit 683c0c1390

View File

@ -217,6 +217,14 @@ class Sanic:
# -------------------------------------------- # # -------------------------------------------- #
# Response Generation Failed # Response Generation Failed
# -------------------------------------------- # # -------------------------------------------- #
if self.debug:
error_body = response.body
if isinstance(error_body, bytes):
try:
error_body = error_body.decode()
except:
pass
log.debug(error_body)
try: try:
response = self.error_handler.response(request, e) response = self.error_handler.response(request, e)