NewsBlur-viq/utils/exception_middleware.py

26 lines
874 B
Python
Raw Normal View History

import inspect
2024-04-24 09:50:42 -04:00
import sys
import traceback
from pprint import pprint
2024-04-24 09:43:56 -04:00
class ConsoleExceptionMiddleware:
def process_exception(self, request, exception):
exc_info = sys.exc_info()
2020-06-13 13:13:20 -04:00
print("######################## Exception #############################")
2024-04-24 09:43:56 -04:00
print(("\n".join(traceback.format_exception(*(exc_info or sys.exc_info())))))
2020-06-13 13:13:20 -04:00
print("----------------------------------------------------------------")
# pprint(inspect.trace()[-1][0].f_locals)
2020-06-13 13:13:20 -04:00
print("################################################################")
2024-04-24 09:43:56 -04:00
# pprint(request)
# print "################################################################"
2020-06-17 03:24:16 -04:00
2020-07-01 18:38:37 -04:00
def __init__(self, get_response=None):
2020-06-17 03:24:16 -04:00
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
return response