"""Sentry connector module.""" import functools import raven import common_config def get_sentry_client(): """Get Sentry client according to configured DSN.""" return raven.Client(common_config.SENTRY_DSN) def sentry_capture_exception(f): """Handle possible exception with Sentry. A decorator to capture and send any Exception instance to Sentry and re-raise it. """ @functools.wraps(f) def wrapper(*args, **kwargs): try: return f(*args, **kwargs) except Exception: sentry_client.captureException() raise return wrapper sentry_client = get_sentry_client()