babalae/better-genshin-impact · error · Exception

自动地脉花执行失败: {e.Message}

Error message

自动地脉花执行失败: {e.Message}

What it means

Thrown by the outer catch-all in AutoLeyLineOutcropTask.Start. Any exception that is not a NormalEndException or TaskCanceledException, and that escapes the try block (from Initialize through RunLeyLineChallenges/RecheckResinAndContinue), is logged at Debug and Error levels, optionally pushes a notification, and is then re-thrown wrapped in a new Exception with the prefix '自动地脉花执行失败: '. The original exception is preserved as the InnerException. This is the top-level error contract for the ley line task — callers see only this wrapper.

Source

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

            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);
            if (_taskParam.IsNotification)
            {
                Notify.Event("AutoLeyLineOutcrop").Error($"任务失败: {e.Message}");
            }

            throw new Exception($"自动地脉花执行失败: {e.Message}", e);
        }
        finally
        {
            try
            {
                try
                {
                    await EnsureExitRewardPage();
                }
                catch (Exception ex)
                {
                    _logger.LogDebug(ex, "地脉花结束后尝试退出奖励界面失败");
                }

                if (!_marksStatus)
                {
                    await OpenCustomMarks();
                }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Inspect the InnerException (and the LogDebug output) to find the root cause — the wrapper message alone is not enough.
  2. Address the specific inner error using its own documented fix (e.g. validate settings, restore missing assets, lower MaxConsecutiveFailures).
  3. If running in a pipeline/scheduler, ensure the caller catches this wrapper and surfaces the InnerException for diagnostics.
  4. Enable Debug logging to capture the full stack trace of the inner exception.

Example fix

// before
_logger.LogError("自动地脉花执行失败:" + e.Message);
throw new Exception($"自动地脉花执行失败: {e.Message}", e);

// after — preserve full inner type so callers can filter
_logger.LogError(e, "自动地脉花执行失败");
throw new Exception($"自动地脉花执行失败: {e.Message}", e);
Defensive patterns

Strategy: try-catch

Try / catch

// At the pipeline/scheduler level, catch the wrapper and inspect InnerException
try
{
    await leyLineTask.Start(ct);
}
catch (Exception e) when (e.Message.StartsWith("自动地脉花执行失败"))
{
    logger.LogError(e.InnerException, "地脉花任务失败,根因: {Msg}", e.InnerException?.Message);
    Notify.Event("AutoLeyLineOutcrop").Error($"任务失败: {e.InnerException?.Message}");
}

Prevention

When it happens

Trigger: Any unhandled exception during the ley line task lifecycle: a FileNotFoundException for missing assets, a strategy/config validation failure, a combat failure that exceeded MaxConsecutiveFailures, a path-resolution failure, or an unexpected NullReferenceException from a vision step.

Common situations: The task encountered any of the specific errors in this list (245, 247-259) that were not caught as normal ends; a transient OCR failure cascaded into a null dereference; a pathing JSON file was corrupted; the game disconnected or the window closed mid-run.

Related errors


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