def excess_pore_pressure_ratio(df):
    """
    Assign the excess pore pressure ratio, if the water pressure u2 is defined. Else, raise ERROR.

    :param df: (DataFrame)
    :return: (DataFrame)
    """
    try:
        u2 = df["u2"]
    except KeyError:
        raise SystemExit("ERROR: u2 not defined in .gef file, change classifier")

    df["excess_pore_pressure_ratio"] = (u2 - df["water_pressure"]) / (
        df["qt"] - df["soil_pressure"]
    )

    return df