Skip to content

Commit

Permalink
Add generic exception catcher
Browse files Browse the repository at this point in the history
  • Loading branch information
ppannuto committed Apr 4, 2015
1 parent 2427329 commit a57682d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chezbetty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def debug(request):

config.add_static_view('static', 'static', cache_max_age=3600)

config.add_route('exception_view', '/exception')

config.add_route('index', '/')

config.add_route('lang', '/lang-{code}')
Expand Down
19 changes: 19 additions & 0 deletions chezbetty/templates/exception.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "base.jinja2" %}
{% block title %}An Unknown Error Occurred{% endblock %}

{% block content %}

<h1>An unknown error occurred</h1>

<h3>Please e-mail [email protected] with a brief description of what you were
doing when this error occurred. Please include the rough time of the error as
well.</h3>

<hr />

<a href="/" class="btn btn-success btn-huge">
Sorry for the trouble. Touch here to return to the home page.
</a>

{% endblock %}

17 changes: 17 additions & 0 deletions chezbetty/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,27 @@
import binascii
import transaction

import traceback

class DepositException(Exception):
pass


###
### Catch-all error page
###

@view_config(route_name='exception_view', renderer='templates/exception.jinja2')
def exception_view(request):
return {}

@view_config(context=Exception)
def exception_view_handler(context, request):
print('An unknown error occurred:')
traceback.print_exc()
return HTTPFound(location=request.route_url('exception_view'))


###
### HTML Pages
###
Expand Down

0 comments on commit a57682d

Please sign in to comment.