The bare raise
keyword is the ticket.
Instead of using logging, capture the Exception in a view with a friendly message. Then, use raise
without an argument, which raises the original exception. Catch the exception and use the Sentry client to capture it and pass it along.
The final view looks like this:
from raven.base import Client
from pyramid.view import view_config
@view_config(context=Exception,
renderer='hitchedup:templates/errors/500.html')
def error(context, request):
"""Display an error message and record it in Sentry."""
client = Client()
try:
raise
except Exception:
client.captureException()
return {}