def guard(f, *args, **kwargs):
    """
    Run a function.

    Return (is_error, result), where ``is_error`` is a boolean indicating whether
    it raised an exception. In that case, ``result`` will be an exception.
    """
    try:
        return (False, f(*args, **kwargs))
    except Exception as e:
        return (True, e)