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

31 lines
514 B
Python
Raw Normal View History

2021-04-30 13:22:58 +00:00
"""
"""
from __future__ import annotations
import functools
import logging
2021-04-30 13:22:58 +00:00
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",
)