EllanJiang/GameFramework · error · GameFrameworkException

Download path is invalid.

Error message

Download path is invalid.

What it means

GameFramework's DownloadManager.AddDownload throws this when the downloadPath parameter is null or an empty string. The download path identifies where the downloaded file will be saved locally, so the manager refuses to create a task without it. It is a fail-fast argument validation thrown as a GameFrameworkException before any agent or task pool work begins.

Solutions

  1. Ensure a non-empty local file path is passed as downloadPath before calling AddDownload
  2. Validate with string.IsNullOrEmpty(downloadPath) at the call site and log/abort early
  3. Check the configuration or data source that supplies the path (config table, remote update info) is populated

Example fix

// before
DownloadManager.AddDownload(null, downloadUri, tag, priority, userData);
// after
string downloadPath = Path.Combine(Application.persistentDataPath, "update.dat");
int serialId = DownloadManager.AddDownload(downloadPath, downloadUri, tag, priority, userData);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(downloadPath)) throw new ArgumentException("downloadPath must be a non-empty local path", nameof(downloadPath));

Type guard

static bool IsValidDownloadPath(string path) => !string.IsNullOrEmpty(path);

Try / catch

try { int id = downloadManager.AddDownload(path, uri, tag, priority, userData); } catch (GameFrameworkException ex) when (ex.Message == "Download path is invalid.") { Log.Error("Invalid download path: '{0}'", path); }

Prevention

When it happens

Trigger: Calling AddDownload (any overload) with downloadPath = null, downloadPath = "", or a path built from an expression that evaluated to empty (e.g. string.Format with missing data, a config field that was never set).

Common situations: Download directory config value left blank in the game's settings table; a path constructed by joining a base folder that is empty; renaming/refactoring code so the path variable is no longer populated before the call.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/b48d9560589a2282. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Download/DownloadManager.cs:398

        public int AddDownload(string downloadPath, string downloadUri, int priority, object userData)
        {
            return AddDownload(downloadPath, downloadUri, null, priority, userData);
        }

        /// <summary>
        /// 增加下载任务。
        /// </summary>
        /// <param name="downloadPath">下载后存放路径。</param>
        /// <param name="downloadUri">原始下载地址。</param>
        /// <param name="tag">下载任务的标签。</param>
        /// <param name="priority">下载任务的优先级。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>新增下载任务的序列编号。</returns>
        public int AddDownload(string downloadPath, string downloadUri, string tag, int priority, object userData)
        {
            if (string.IsNullOrEmpty(downloadPath))
            {
                throw new GameFrameworkException("Download path is invalid.");
            }

            if (string.IsNullOrEmpty(downloadUri))
            {
                throw new GameFrameworkException("Download uri is invalid.");
            }

            if (TotalAgentCount <= 0)
            {
                throw new GameFrameworkException("You must add download agent first.");
            }

            DownloadTask downloadTask = DownloadTask.Create(downloadPath, downloadUri, tag, priority, m_FlushSize, m_Timeout, userData);
            m_TaskPool.AddTask(downloadTask);
            return downloadTask.SerialId;
        }

        /// <summary>

View on GitHub (pinned to d0c010b051)