babalae/better-genshin-impact · error · Exception

冒险之证未找到国家: {country}

Error message

冒险之证未找到国家: {country}

What it means

Thrown by FindAndClickCountry when OCR over the handbook country list finds no entry whose Text contains the target country substring. Note the special-case mapping where '挪德卡莱' is searched as '挪德卡'.

Source

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

    {
        if (_mapSettingButtonRo == null)
        {
            return false;
        }

        using var capture = CaptureToRectArea();
        return capture.Find(_mapSettingButtonRo).IsExist();
    }

    private async Task FindAndClickCountry(string country)
    {
        var match = country == "挪德卡莱" ? "挪德卡" : country;
        using var capture = CaptureToRectArea();
        var list = capture.FindMulti(_ocrRoThis);
        var target = list.FirstOrDefault(r => r.Text.Contains(match, StringComparison.Ordinal));
        if (target == null)
        {
            throw new Exception($"冒险之证未找到国家: {country}");
        }

        target.Click();
    }

    private async Task<bool> TryOpenBigMapFromHandbook()
    {
        for (var attempt = 0; attempt < 2; attempt++)
        {
            var button = FindHandbookTrackActionButtonByIcon();
            if (button == null)
            {
                break;
            }

            button.Click();
            _logger.LogDebug("通过图标识别点击冒险之证底部操作按钮,第{Attempt}次", attempt + 1);
            await Delay(1500, _ct);

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Ensure the handbook is scrolled so the target country is visible before OCR.
  2. Improve OCR accuracy (resolution, language, ROI) so country names read correctly.
  3. Verify the country string passed matches in-game text (and the 挪德卡莱→挪德卡 abbreviation rule still applies).
  4. Confirm the player has unlocked that country's handbook entries.
Defensive patterns

Strategy: try-catch

Try / catch

try { await FindAndClickCountry(country); }
catch (Exception ex) when (ex.Message.Contains("冒险之证未找到国家"))
{
    _logger.LogWarning("未在冒险之证识别到国家 {Country},尝试滚动后重试", country);
    // scroll handbook list, then retry
}

Prevention

When it happens

Trigger: capture.FindMulti(_ocrRoThis) returns a list; FirstOrDefault with r.Text.Contains(match) yields null → throw. match = (country == "挪德卡莱" ? "挪德卡" : country).

Common situations: OCR misreads the country name; the handbook isn't scrolled to show the target country; the country isn't unlocked in the player's handbook; UI text changed.

Related errors


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