def google_api_exception_shield()

in common/big_query/big_query_exceptions.py [0:0]


def google_api_exception_shield(target):
    """
    Decorator to shield a function from exceptions raised by the Google API.
    Converts specific Google API exceptions into more specific BigQuery
    exceptions.
    """

    @wraps(target)
    def inner(*args, **kwargs):
        try:
            return target(*args, **kwargs)
        except GoogleAPICallError as e:
            raise BigQueryExecutionError(f"Error: {e}") from e
        except concurrent.futures.TimeoutError as e:
            raise BigQueryTimeoutError(f"Error: {e}") from e

    return inner