{"record":{"id":"e0b36707a8bf23e8","repo":"EllanJiang/GameFramework","slug":"can-not-parse-data-bytes-with-exception-0","errorCode":null,"errorMessage":"Can not parse data bytes with exception '{0}'.","messagePattern":"Can not parse data bytes with exception '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Base/DataProvider/DataProvider.cs","lineNumber":370,"sourceCode":"            }\n\n            if (startIndex < 0 || length < 0 || startIndex + length > dataBytes.Length)\n            {\n                throw new GameFrameworkException(\"Start index or length is invalid.\");\n            }\n\n            try\n            {\n                return m_DataProviderHelper.ParseData(m_Owner, dataBytes, startIndex, length, userData);\n            }\n            catch (Exception exception)\n            {\n                if (exception is GameFrameworkException)\n                {\n                    throw;\n                }\n\n                throw new GameFrameworkException(Utility.Text.Format(\"Can not parse data bytes with exception '{0}'.\", exception), exception);\n            }\n        }\n\n        /// <summary>\n        /// 设置资源管理器。\n        /// </summary>\n        /// <param name=\"resourceManager\">资源管理器。</param>\n        internal void SetResourceManager(IResourceManager resourceManager)\n        {\n            if (resourceManager == null)\n            {\n                throw new GameFrameworkException(\"Resource manager is invalid.\");\n            }\n\n            m_ResourceManager = resourceManager;\n        }\n\n        /// <summary>","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Base/DataProvider/DataProvider.cs#L352-L388","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ntry { table.ParseData(bytes, 0, bytes.Length, userData); }\ncatch (Exception e) { Log.Error(e.ToString()); }\n// after\ntry { table.ParseData(bytes, 0, bytes.Length, userData); }\ncatch (GameFrameworkException e)\n{\n    Log.Error(\"Table parse failed: {0}\", e.InnerException ?? e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { table.ParseData(bytes, 0, bytes.Length, userData); }\ncatch (GameFrameworkException ex)\n{\n    var root = ex.InnerException ?? ex;\n    Log.Error(\"Parse failed: {0}\", root);\n}","preventionTips":["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."],"tags":["parse-failure","wrapped-exception","dataprovider"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}