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
- Read the InnerException (and its stack trace) to find the real parser failure and fix the helper or the data file accordingly.
- Re-export/fix the data file: correct encoding, column count, and row format expected by your IDataProviderHelper.
- Catch GameFrameworkException around ParseData and inspect ex.InnerException to build a user-facing load-failure message.
- 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
- Always inspect InnerException — the outer message only says parsing failed.
- Unit-test your IDataProviderHelper against real and edge-case data files.
- Keep data file schema/encoding in sync with parser code; validate exports before shipping.
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
- Load data failure in data provider helper, data asset name
- Can not parse data string with exception
- Ensure size is invalid.
- You must set resource manager first.
- You must set data provider helper first.
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)