EllanJiang/GameFramework · error · GameFrameworkException

Results is invalid.

Error message

Results is invalid.

What it means

GetAllDataTables(List<DataTableBase>) throws this when the results list argument is null. The method clears and fills the caller-supplied list, so a null destination is invalid; it does not allocate a list for you.

Solutions

  1. Pass a new or existing non-null List<DataTableBase>: new List<DataTableBase>().
  2. Initialize the list field/property before calling.
  3. Wrap in try-catch if the list provenance is dynamic.

Example fix

// before
dataTableManager.GetAllDataTables(results); // results is null
// after
List<DataTableBase> results = new List<DataTableBase>();
dataTableManager.GetAllDataTables(results);
Defensive patterns

Strategy: validation

Validate before calling

List<DataTableBase> results = resultsList ?? new List<DataTableBase>();
dataTableManager.GetAllDataTables(results);

Type guard

bool IsValidResultsList(List<DataTableBase> list) => list != null;

Try / catch

try { dataTableManager.GetAllDataTables(results); }
catch (GameFrameworkException ex) { Log.Error("Results list must be non-null: {0}", ex.Message); }

Prevention

When it happens

Trigger: Calling dataTableManager.GetAllDataTables(null), or passing a property/field of type List<DataTableBase> that was never initialized.

Common situations: Reusing a cached list variable that was declared but never assigned; passing a LINQ result or method return that was null.

Related errors


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

Appendix: source

Thrown at GameFramework/DataTable/DataTableManager.cs:286

            int index = 0;
            DataTableBase[] results = new DataTableBase[m_DataTables.Count];
            foreach (KeyValuePair<TypeNamePair, DataTableBase> dataTable in m_DataTables)
            {
                results[index++] = dataTable.Value;
            }

            return results;
        }

        /// <summary>
        /// 获取所有数据表。
        /// </summary>
        /// <param name="results">所有数据表。</param>
        public void GetAllDataTables(List<DataTableBase> results)
        {
            if (results == null)
            {
                throw new GameFrameworkException("Results is invalid.");
            }

            results.Clear();
            foreach (KeyValuePair<TypeNamePair, DataTableBase> dataTable in m_DataTables)
            {
                results.Add(dataTable.Value);
            }
        }

        /// <summary>
        /// 创建数据表。
        /// </summary>
        /// <typeparam name="T">数据表行的类型。</typeparam>
        /// <returns>要创建的数据表。</returns>
        public IDataTable<T> CreateDataTable<T>() where T : class, IDataRow, new()
        {
            return CreateDataTable<T>(string.Empty);
        }

View on GitHub (pinned to d0c010b051)