babalae/better-genshin-impact · error · Exception

国家未配置

Error message

国家未配置

What it means

Thrown by ValidateSettings when _taskParam.Country is null, empty, or whitespace. The Country field selects which region's ley line positions to navigate to (e.g. '蒙德', '璃月', '稻妻', '须弥', '枫丹'). The task uses it as a dictionary key into _configData.LeyLinePositions and _configData.MapPositions. Without a country the task cannot determine which map region to search or which pathing routes to use.

Source

Thrown at BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropTask.cs:191

    }

    private void ValidateSettings()
    {
        _taskParam.FightConfig ??= new AutoLeyLineOutcropFightConfig();

        if (string.IsNullOrWhiteSpace(_taskParam.LeyLineOutcropType))
        {
            throw new Exception("地脉花类型未选择");
        }

        if (_taskParam.LeyLineOutcropType != "启示之花" && _taskParam.LeyLineOutcropType != "藏金之花")
        {
            throw new Exception("地脉花类型无效,请重新选择");
        }

        if (string.IsNullOrWhiteSpace(_taskParam.Country))
        {
            throw new Exception("国家未配置");
        }

        if (!string.IsNullOrWhiteSpace(_taskParam.FriendshipTeam) && string.IsNullOrWhiteSpace(_taskParam.Team))
        {
            throw new Exception("配置好感队时必须配置战斗队伍");
        }

        if (_taskParam.Count < 1)
        {
            _taskParam.Count = 1;
        }

        if (string.IsNullOrWhiteSpace(_taskParam.FightConfig.StrategyName) && _taskParam.Timeout > 0)
        {
            _taskParam.FightConfig.Timeout = _taskParam.Timeout;
        }

        if (_taskParam.FightConfig.Timeout <= 0)

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Select a country/region in the ley line task configuration before starting.
  2. Set taskParam.Country to one of the supported region names (e.g. "蒙德", "璃月", "稻妻", "须弥", "枫丹").
  3. If loading from JSON, ensure the Country field is present and correctly spelled in Simplified Chinese.

Example fix

// before
var param = new AutoLeyLineOutcropParam { LeyLineOutcropType = "启示之花" };
// Country missing

// after
var param = new AutoLeyLineOutcropParam
{
    LeyLineOutcropType = "启示之花",
    Country = "蒙德"
};
Defensive patterns

Strategy: validation

Validate before calling

// Before starting, validate the country is set
if (string.IsNullOrWhiteSpace(taskParam.Country))
{
    Logger.LogError("请选择国家/地区");
    return;
}

Type guard

public static bool HasValidCountry(AutoLeyLineOutcropParam param)
{
    return !string.IsNullOrWhiteSpace(param.Country);
}

Prevention

When it happens

Trigger: AutoLeyLineOutcropParam was constructed or deserialized without setting Country. ValidateSettings is the first code to run in Initialize and checks Country after the ley line type validations.

Common situations: User selected a ley line type but did not select a country/region in the UI; a configuration file or script omitted the Country field; the country dropdown defaulted to empty.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/c7cec6e4de7943a8. Report an issue: GitHub.