#  Copyright (C) 2024
#  ABM, Moscow
#
#  UNPUBLISHED PROPRIETARY MATERIAL.
#  ALL RIGHTS RESERVED.
#
#  Authors: Mike Orlov <m.orlov@abm-jsc.ru>
from typing import Any


def raise_if(condition: Any, exception: Exception | type[Exception], *args) -> None:
    if condition:
        if isinstance(exception, type) and args:
            exception = exception(*args)
        raise exception


def raise_if_not(condition: Any, exception: Exception | type[Exception], *args) -> None:
    if not condition:
        if isinstance(exception, type) and args:
            exception = exception(*args)
        raise exception
