Skip to content

Instantly share code, notes, and snippets.

@gcarothers
Created May 20, 2015 15:26
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 gcarothers/874b9df262dd2b20fcde to your computer and use it in GitHub Desktop.
Save gcarothers/874b9df262dd2b20fcde to your computer and use it in GitHub Desktop.
@view_config(context=Exception)
def exception_view(context, request):
# Check to see if debug toolbar is enabled.
from pyramid.interfaces import ITweens
tweens = request.registry.queryUtility(ITweens)
if tweens:
tween_list = tweens.explicit or tweens.implicit()
tween_names = zip(*tween_list)[0]
if tween_list and 'pyramid_debugtoolbar.toolbar_tween_factory' in\
tween_names:
raise # Re-raise exception for debug toolbar.
# Exception handler goes here ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment