From 683c0c1390e723b69d2e5e9651bcca8d9baee030 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Wed, 28 Dec 2016 18:17:22 +0900 Subject: [PATCH] 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. --- sanic/sanic.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sanic/sanic.py b/sanic/sanic.py index 033b1e9d..2f5a405a 100644 --- a/sanic/sanic.py +++ b/sanic/sanic.py @@ -217,6 +217,14 @@ class Sanic: # -------------------------------------------- # # 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: response = self.error_handler.response(request, e)