babalae/better-genshin-impact · info · Exception

树脂耗尽,任务结束

Error message

树脂耗尽,任务结束

What it means

Thrown by AutoLeyLineOutcropTask.Start when resin exhaustion mode is enabled and HandleResinExhaustionMode returns a run count of 0 or less. This means the resin calculation (CalCountByResin) determined there is no resin (original, condensed, transient, or fragile) remaining to spend on ley line challenges. The throw is intended as a normal-end signal but is thrown as a plain System.Exception rather than NormalEndException, so it is NOT caught by the 'e is NormalEndException or TaskCanceledException' filter above it — it falls through to the generic catch and gets re-wrapped as '自动地脉花执行失败'.

Source

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

    public AutoLeyLineOutcropTask(AutoLeyLineOutcropParam taskParam, bool oneDragonMode = false)
    {
        _taskParam = taskParam;
        _oneDragonMode = oneDragonMode;
    }

    public async Task Start(CancellationToken ct)
    {
        _ct = ct;

        try
        {
            Initialize();
            EnsureMaskOverlayVisible();
            var runTimesValue = await HandleResinExhaustionMode();
            if (runTimesValue <= 0)
            {
                throw new Exception("树脂耗尽,任务结束");
            }

            await PrepareForLeyLineRun();
            await RunLeyLineChallenges();

            if (_taskParam.IsResinExhaustionMode)
            {
                await RecheckResinAndContinue();
            }
        }
        catch (Exception e) when (e is NormalEndException or TaskCanceledException)
        {
            Logger.LogInformation("任务结束:{Msg}", e.Message);
        }
        catch (Exception e)
        {
            _logger.LogDebug(e, "自动地脉花执行失败");
            _logger.LogError("自动地脉花执行失败:" + e.Message);

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Check that you actually have resin (open the game and verify the resin counter).
  2. If resin exists but was misread, ensure the game is on the main world screen where the resin counter is visible before starting the task.

Example fix

// before
if (runTimesValue <= 0)
{
    throw new Exception("树脂耗尽,任务结束");
}

// after — use NormalEndException so the normal-end catch handles it cleanly
if (runTimesValue <= 0)
{
    throw new NormalEndException("树脂耗尽,任务结束");
}
Defensive patterns

Strategy: validation

Validate before calling

// Before starting, check resin availability if exhaustion mode is on
if (_taskParam.IsResinExhaustionMode)
{
    var result = await CalCountByResin();
    if (result.Count <= 0)
    {
        Logger.LogInformation("树脂已耗尽,跳过地脉花任务");
        return; // exit gracefully, no exception
    }
}

Try / catch

// In the caller, treat resin exhaustion as a normal end
catch (Exception e) when (e.Message.Contains("树脂耗尽"))
{
    Logger.LogInformation("树脂耗尽,任务正常结束");
    // do not re-throw; treat as normal completion
}

Prevention

When it happens

Trigger: User enabled '树脂耗尽模式' (resin exhaustion mode) in the ley line task settings, and when the task starts it reads the current resin count from the game screen. If total available resin yields 0 possible runs, this exception fires immediately before any navigation begins.

Common situations: All resin has already been spent manually or by other tasks; the resin OCR/reading step returned 0 due to a recognition failure; the game is on a screen where resin is not visible and was misread as 0; first run of the day with no condensed/fragile resin stocked.

Related errors


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