Skip to content

Commit

Permalink
Set a custom 500 handler to print exception so we can see it in our l…
Browse files Browse the repository at this point in the history
…ogs.
  • Loading branch information
emperorcezar committed Nov 5, 2015
1 parent b350c62 commit d71bb29
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions chipy_org/apps/main/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import datetime

import sys
import traceback

from django.http import HttpResponseServerError
from django.template import loader, Context
from django.views.generic import TemplateView
from chipy_org.apps.meetings.models import Meeting, RSVP
from chipy_org.apps.meetings.forms import RSVPForm
Expand Down Expand Up @@ -36,3 +42,13 @@ def get_context_data(self, **kwargs):
context['rsvp_form'] = RSVPForm(self.request)

return context

def custom_500(request):
t = loader.get_template('500.html')

print sys.exc_info()
type, value, tb = sys.exc_info()
return HttpResponseServerError(t.render(Context({
'exception_value': value,
'value': type,
'tb': traceback.format_exception(type, value, tb)})))

0 comments on commit d71bb29

Please sign in to comment.