EllanJiang/GameFramework · error · GameFrameworkException

Can not parse data row string for data table

Error message

Can not parse data row string for data table '{0}' with exception '{1}'.

What it means

Wrapping error thrown by DataTable<T>.AddDataRow(string) when parsing the data row text fails with any exception other than a GameFrameworkException. The original parse exception is preserved as InnerException and the message names the table (TypeNamePair of row type and table name) plus the underlying exception.

Solutions

  1. Inspect InnerException to find the actual parse failure.
  2. Check the row string matches the table's column layout and separator.
  3. Regenerate/export the data file from source; do not hand-edit.
  4. Validate field formats (numbers, enums) against the T class definition.

Example fix

// before
int count = string.Concat(parts).Split('\t').Length; // hand-edited row, wrong columns
table.AddDataRow(text);
// after
// re-export the row so the tab-separated columns match the DataRow class
table.AddDataRow(text); // with try/catch on GameFrameworkException reading InnerException
Defensive patterns

Strategy: try-catch

Validate before calling

if (string.IsNullOrWhiteSpace(rowText)) throw new InvalidDataException("Empty data row string");

Try / catch

try { table.AddDataRow(rowText); } catch (GameFrameworkException ex) { var root = ex.InnerException; Log.Error($"Bad row for {table.Name}: {root}"); }

Prevention

When it happens

Trigger: Calling AddDataRow with a malformed data row string whose text cannot be parsed into T by the data provider, e.g. wrong column count, bad number format, or a parsing helper throwing (IndexOutOfRange, FormatException, NullReferenceException).

Common situations: Editing spreadsheet-exported text files by hand; locale/decimal-separator changes; schema drift between the row class and the file; empty or truncated line.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/DataTable/DataTableManager.DataTable.cs:393

                try
                {
                    T dataRow = new T();
                    if (!dataRow.ParseDataRow(dataRowString, userData))
                    {
                        return false;
                    }

                    InternalAddDataRow(dataRow);
                    return true;
                }
                catch (Exception exception)
                {
                    if (exception is GameFrameworkException)
                    {
                        throw;
                    }

                    throw new GameFrameworkException(Utility.Text.Format("Can not parse data row string for data table '{0}' with exception '{1}'.", new TypeNamePair(typeof(T), Name), exception), exception);
                }
            }

            /// <summary>
            /// 增加数据表行。
            /// </summary>
            /// <param name="dataRowBytes">要解析的数据表行二进制流。</param>
            /// <param name="startIndex">数据表行二进制流的起始位置。</param>
            /// <param name="length">数据表行二进制流的长度。</param>
            /// <param name="userData">用户自定义数据。</param>
            /// <returns>是否增加数据表行成功。</returns>
            public override bool AddDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
            {
                try
                {
                    T dataRow = new T();
                    if (!dataRow.ParseDataRow(dataRowBytes, startIndex, length, userData))
                    {

View on GitHub (pinned to d0c010b051)