babalae/better-genshin-impact · error · InvalidOperationException

传送失败

Error message

传送失败

What it means

Thrown by TpWithRetries after the teleport retry loop (3 attempts) in TpTask.cs exhausts all iterations. Each attempt calls TpOnce, and the loop swallows both TpPointNotActivate and generic non-task-stop exceptions, logging a warning. Only when every attempt fails does it throw InvalidOperationException("传送失败"). This means the single-teleport pipeline (open map → pan → click → confirm) never succeeded within the allowed retries.

Source

Thrown at BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs:1230

            catch (TpPointNotActivate e)
            {
                // 未激活点位的详情面板会遮挡后续地图操作,重试前先关闭。
                // 最后一次失败也需要执行清理,避免影响脚本组中的下一个任务。
                Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE);
                await Delay(300, ct);
                // throw; // 不抛出异常,继续重试
                Logger.LogWarning(e.Message + "  重试");
            }
            catch (Exception e) when (IsTaskStopException(e))
            {
                throw;
            }
            catch (Exception)
            {
            }
        }

        throw new InvalidOperationException("传送失败");
    }

    /// <summary>
    /// 移动地图到指定传送点位置
    /// 可能会移动不对,所以可以重试此方法
    /// </summary>
    /// <param name="x">目标x坐标</param>
    /// <param name="y">目标y坐标</param>
    /// <param name="mapName">地图名称</param>
    /// <param name="finalZoomLevel">到达目标点的最小缩放等级,只在 MapZoomEnabled 为 True 生效</param>
    public async Task MoveMapTo(double x, double y, string mapName, double finalZoomLevel = 2)
    {
        await MoveMapToCore(x, y, mapName, finalZoomLevel, true, 0);
    }

    /// <summary>
    /// 点击大地图上的指定坐标。
    /// </summary>

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Ensure the game window is focused and in the foreground before the teleport task starts.
  2. Verify the target teleport point is activated in-game (unlock it manually first).
  3. Increase the retry count or per-attempt timeout in the teleport configuration if lag is suspected.
  4. Check that the map name and coordinates are valid and reachable for the current game state.
  5. Inspect the logged warnings from each retry iteration for the root cause (e.g. recognition failures, panel not found).

Example fix

// before: catch swallows all non-task-stop exceptions
// catch (Exception) { }
// after: log the swallowed exception for diagnostics
catch (Exception e)
{
    Logger.LogWarning($"传送重试异常: {e.Message}");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (string.IsNullOrEmpty(mapName)) throw new ArgumentException("mapName must not be empty");
if (double.IsNaN(tpX) || double.IsNaN(tpY)) throw new ArgumentException("coordinates must be valid");

Try / catch

try
{
    await task.TpWithRetries(x, y, mapName, force);
}
catch (InvalidOperationException ex) when (ex.Message == "传送失败")
{
    Logger.LogWarning($"Teleport failed after retries for ({x}, {y}) on {mapName}: {ex.Message}");
    // Optionally re-initiate the teleport task or notify the user
}

Prevention

When it happens

Trigger: Called from TpWithRetries(tpX, tpY, mapName, force) when TpOnce throws 3 consecutive times. Each failure can stem from TpPointNotActivate (teleport point not activated, ESC pressed to dismiss), an unhandled exception during map interaction, or any recognition failure that propagates as a non-task-stop exception.

Common situations: Game window lost focus or is occluded during teleport; the target teleport point is locked/unactivated; the map UI didn't open in time; network/lag caused the teleport confirmation panel to not appear; wrong mapName or coordinates pointing to an unreachable area.

Related errors


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