1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
royalnet/royalpack/bolts/sentry.py

30 lines
513 B
Python
Raw Normal View History

2021-04-30 13:22:58 +00:00
"""
"""
from __future__ import annotations
import functools
import logging
import sentry_sdk
log = logging.getLogger(__name__)
def capture_errors(f):
@functools.wraps(f)
async def decorated(**f_kwargs):
try:
return await f(**f_kwargs)
except Exception as e:
log.error(f"Captured error: {e!r}")
if sentry_sdk.Hub.current is not None:
sentry_sdk.capture_exception(error=e)
return decorated
__all__ = (
"capture_errors",
)