"""Utilities related to exception handling.""" import functools from connectors import sentry 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.sentry_client.captureException() raise return wrapper