Merge pull request #306 from zkanda/always-log-error-exception

Always log if there's an exception occurred.
This commit is contained in:
Raphael Deem 2017-01-19 00:22:46 -08:00 committed by GitHub
commit 1ad7b95437

View File

@ -173,6 +173,7 @@ class Handler:
try: try:
response = handler(request=request, exception=exception) response = handler(request=request, exception=exception)
except: except:
log.error(format_exc())
if self.sanic.debug: if self.sanic.debug:
response_message = ( response_message = (
'Exception raised in exception handler "{}" ' 'Exception raised in exception handler "{}" '
@ -185,6 +186,7 @@ class Handler:
return response return response
def default(self, request, exception): def default(self, request, exception):
log.error(format_exc())
if issubclass(type(exception), SanicException): if issubclass(type(exception), SanicException):
return text( return text(
'Error: {}'.format(exception), 'Error: {}'.format(exception),