Skip to content

Instantly share code, notes, and snippets.

@zbyte64
Created August 3, 2012 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbyte64/3252713 to your computer and use it in GitHub Desktop.
Save zbyte64/3252713 to your computer and use it in GitHub Desktop.
Debug Middleware
from django.views.debug import technical_500_response
import sys
import webbrowser
import tempfile
class BrowserExceptionMiddleware(object):
def process_exception(self, request, exception):
response = technical_500_response(request, *sys.exc_info())
path = tempfile.mkstemp(suffix='html')[1]
open(path, 'w').write(response.content)
webbrowser.open_new_tab('file://'+path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment