def convert_to_nullable(input_val, cast_function):
    """For non-null input_val, apply cast_function and return result if successful; for null input_val, return None.

    Args:
        input_val (Any): The value to attempt to convert to either a None or the type specified by cast_function.
            The recognized null values are '.', None, '', and 'NULL'
        cast_function (Callable[[Any], Any]): A function to cast the input_val to some specified type; should raise an
            error if this cast fails.

    Returns:
        None if input is the null value.
        An appropriately cast value if input is not null and the cast is successful.

    Raises:
        Error: whatever error is provided by cast_function if the cast fails.
    """
    if input_val in ['.', None, '', 'NULL']:
        result = None
    else:
        result = cast_function(input_val)
    return result