def call_safe(*args, **kwargs):
    """
    Safely call function that involves a report. If function raises an error,
    log the error with report.log_error() method.
    """

    report, func, *args = args
    if not callable(func):
        func = getattr(report, func)
    try:
        return func(*args, **kwargs)
    except Exception as ex:
        msg = f"{type(ex).__name__}: {ex}"
        report.log_error(msg, code=ex)
        return None