Skip to content

Commit

Permalink
Print stacktrace on unintended HTTP exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaspuff committed Aug 9, 2017
1 parent c9f63af commit 00b973b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tomodachi/transport/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@ async def func() -> web.Response:
response = e
response.headers[hdrs.SERVER] = server_header or ''
response.body = str(e).encode('utf-8')
except Exception as e:
error_handler = context.get('_http_error_handler', {}).get(500, None)
if not context.get('log_level') or context.get('log_level') in ['DEBUG']:
traceback.print_exception(e.__class__, e, e.__traceback__)
if error_handler:
response = await error_handler(request)
response.headers[hdrs.SERVER] = server_header or ''
else:
response = web.HTTPInternalServerError()
response.headers[hdrs.SERVER] = server_header or ''
response.body = b''
finally:
if not request.transport:
response = web.Response(status=499)
Expand Down

0 comments on commit 00b973b

Please sign in to comment.