EllanJiang/GameFramework · error · GameFrameworkException

Can not parse data bytes with exception

Error message

Can not parse data bytes with exception '{0}'.

What it means

ParseData wraps the IDataProviderHelper.ParseData call in a try-catch: if the helper throws a non-GameFrameworkException, it is rethrown as GameFrameworkException('Can not parse data bytes with exception ...') with the original exception as InnerException. GameFrameworkExceptions from the helper are rethrown as-is. This uniformizes parse failures so callers can catch one exception type while retaining the root cause.

Solutions

  1. Read the InnerException (and its stack trace) to find the real parser failure and fix the helper or the data file accordingly.
  2. Re-export/fix the data file: correct encoding, column count, and row format expected by your IDataProviderHelper.
  3. Catch GameFrameworkException around ParseData and inspect ex.InnerException to build a user-facing load-failure message.
  4. Add unit tests for the helper against representative (and edge-case) data files to surface parse exceptions early.

Example fix

// before
try { table.ParseData(bytes, 0, bytes.Length, userData); }
catch (Exception e) { Log.Error(e.ToString()); }
// after
try { table.ParseData(bytes, 0, bytes.Length, userData); }
catch (GameFrameworkException e)
{
    Log.Error("Table parse failed: {0}", e.InnerException ?? e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { table.ParseData(bytes, 0, bytes.Length, userData); }
catch (GameFrameworkException ex)
{
    var root = ex.InnerException ?? ex;
    Log.Error("Parse failed: {0}", root);
}

Prevention

When it happens

Trigger: Any exception thrown inside your IDataProviderHelper.ParseData implementation — format parsing errors (malformed table text/bytes), ArgumentException from the parser, TargetInvocationException from reflection-based row filling, NullReferenceException in row conversion, etc.

Common situations: Malformed or wrong-encoding data files (e.g. table text saved with wrong encoding or wrong column count); a DataTableHelper whose parse logic throws on unexpected cells; version drift between the exported data file schema and the parser code.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Base/DataProvider/DataProvider.cs:370

            }

            if (startIndex < 0 || length < 0 || startIndex + length > dataBytes.Length)
            {
                throw new GameFrameworkException("Start index or length is invalid.");
            }

            try
            {
                return m_DataProviderHelper.ParseData(m_Owner, dataBytes, startIndex, length, userData);
            }
            catch (Exception exception)
            {
                if (exception is GameFrameworkException)
                {
                    throw;
                }

                throw new GameFrameworkException(Utility.Text.Format("Can not parse data bytes with exception '{0}'.", exception), exception);
            }
        }

        /// <summary>
        /// 设置资源管理器。
        /// </summary>
        /// <param name="resourceManager">资源管理器。</param>
        internal void SetResourceManager(IResourceManager resourceManager)
        {
            if (resourceManager == null)
            {
                throw new GameFrameworkException("Resource manager is invalid.");
            }

            m_ResourceManager = resourceManager;
        }

        /// <summary>

View on GitHub (pinned to d0c010b051)