How to catch any exception in python and print stack trace (DJANGO)
django, python
Solution
You can do something like this
import traceback
from django.http import HttpReponse
def view(request):
try:
#throw exception
except:
tb = traceback.format_exc()
return HttpResponse(tb)
# normal flow
Problem
I have like this: ``` try: #bunch of code except: return HttpResponse.... ``` I want to send an error to client and to print stack trace on console. How can i do that?