mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-03-02 18:10:36 +00:00
19 lines
510 B
Python
19 lines
510 B
Python
"""Assertion_service."""
|
|
import contextlib
|
|
from typing import Generator
|
|
|
|
import sentry_sdk
|
|
from flask import current_app
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def safe_assertion(condition: bool) -> Generator[bool, None, None]:
|
|
try:
|
|
yield True
|
|
except AssertionError as e:
|
|
if not condition:
|
|
sentry_sdk.capture_exception(e)
|
|
current_app.logger.exception(e)
|
|
if current_app.config["ENV_IDENTIFIER"] in ["local_development", "unit_testing"]:
|
|
raise e
|