EllanJiang/GameFramework · error · GameFrameworkException
Results is invalid.
Error message
Results is invalid.
What it means
Generic null-guard inside the List-based GetTaskInfos overload of TaskPool: it fires when the caller passes a null results list to fill. It is a defensive parameter validation, not a state error; callers should pass an initialized List<TaskInfo> (or use the allocating overload that creates one internally).
Solutions
- Pass a new (or reused, non-null) List<TaskInfo>: results = results ?? new List<TaskInfo>()
- Initialize the results list field at declaration or in Awake
- Note the method Clears the list, so you may safely reuse one list instance
Example fix
// before
List<TaskInfo> results; // never assigned
m_TaskPool.GetTaskInfos("download", results);
// after
var results = new List<TaskInfo>();
m_TaskPool.GetTaskInfos("download", results); Defensive patterns
Strategy: validation
Validate before calling
if (results == null) results = new List<TaskInfo>(); taskPool.GetTaskInfos(tag, results);
Try / catch
try { taskPool.GetTaskInfos(tag, results); }
catch (GameFrameworkException ex) { Debug.LogError($"GetTaskInfos failed: {ex.Message}"); } Prevention
- Initialize list fields at declaration or Awake
- Reuse one persistent list (the method clears it)
- Never pass unassigned locals
When it happens
Trigger: Calling GetTaskInfos(tag, null), commonly when the results list is a field that hasn't been initialized, or when reusing a list variable that was never assigned.
Common situations: Debug/monitoring code building task reports; mis-ordered initialization where the list is created after the first query.
Related errors
- Task agent is invalid.
- Download agent helper is invalid.
- Task is invalid.
- Load resource agent helper is invalid.
- Resource helper is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/8791e797fe8f82ba.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Base/TaskPool/TaskPool.cs:185
/// <param name="tag">要获取信息的任务的标签。</param>
/// <returns>任务的信息。</returns>
public TaskInfo[] GetTaskInfos(string tag)
{
List<TaskInfo> results = new List<TaskInfo>();
GetTaskInfos(tag, results);
return results.ToArray();
}
/// <summary>
/// 根据任务的标签获取任务的信息。
/// </summary>
/// <param name="tag">要获取信息的任务的标签。</param>
/// <param name="results">任务的信息。</param>
public void GetTaskInfos(string tag, List<TaskInfo> results)
{
if (results == null)
{
throw new GameFrameworkException("Results is invalid.");
}
results.Clear();
foreach (ITaskAgent<T> workingAgent in m_WorkingAgents)
{
T workingTask = workingAgent.Task;
if (workingTask.Tag == tag)
{
results.Add(new TaskInfo(workingTask.SerialId, workingTask.Tag, workingTask.Priority, workingTask.UserData, workingTask.Done ? TaskStatus.Done : TaskStatus.Doing, workingTask.Description));
}
}
foreach (T waitingTask in m_WaitingTasks)
{
if (waitingTask.Tag == tag)
{
results.Add(new TaskInfo(waitingTask.SerialId, waitingTask.Tag, waitingTask.Priority, waitingTask.UserData, TaskStatus.Todo, waitingTask.Description));
}View on GitHub (pinned to d0c010b051)