{"record":{"id":"139520eaf7496ddd","repo":"EllanJiang/GameFramework","slug":"can-not-parse-data-string-with-exception-0","errorCode":null,"errorMessage":"Can not parse data string with exception '{0}'.","messagePattern":"Can not parse data string with exception '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Base/DataProvider/DataProvider.cs","lineNumber":287,"sourceCode":"            }\n\n            if (dataString == null)\n            {\n                throw new GameFrameworkException(\"Data string is invalid.\");\n            }\n\n            try\n            {\n                return m_DataProviderHelper.ParseData(m_Owner, dataString, 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 string with exception '{0}'.\", exception), exception);\n            }\n        }\n\n        /// <summary>\n        /// 解析内容。\n        /// </summary>\n        /// <param name=\"dataBytes\">要解析的内容二进制流。</param>\n        /// <returns>是否解析内容成功。</returns>\n        public bool ParseData(byte[] dataBytes)\n        {\n            if (dataBytes == null)\n            {\n                throw new GameFrameworkException(\"Data bytes is invalid.\");\n            }\n\n            return ParseData(dataBytes, 0, dataBytes.Length, null);\n        }\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Base/DataProvider/DataProvider.cs#L269-L305","documentation":"ParseData(string, object) wraps the helper's ParseData call in a try/catch. If the helper throws any exception other than a GameFrameworkException, it is re-wrapped as this GameFrameworkException carrying the original exception's message and preserved as InnerException. It means the helper itself crashed while parsing the string.","triggerScenarios":"IDataProviderHelper.ParseData(owner, dataString, userData) throws (NullReferenceException, FormatException, custom helper bug, etc.) during string parsing.","commonSituations":"Malformed JSON/XML/config text fed to the helper; helper assumes a field or structure that is absent; bug in a custom data provider helper implementation.","solutions":["Inspect the InnerException of this GameFrameworkException to find the real cause.","Validate/repair the data string format before parsing.","Fix the throwing code path inside the custom IDataProviderHelper implementation.","Version-check the data string against what the helper expects."],"exampleFix":"// before\nthrow new GameFrameworkException(Utility.Text.Format(\"Can not parse data string with exception '{0}'.\", exception), exception);\n// after (caller side)\ntry { dataProvider.ParseData(text, null); }\ncatch (GameFrameworkException e) { Log.Error(\"Parse failed: {0}\", e.InnerException); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { dataProvider.ParseData(text, null); }\ncatch (GameFrameworkException e) when (e.Message.StartsWith(\"Can not parse data string\")) { Log.Error(\"Helper parse crash: {0}\", e.InnerException); }","preventionTips":["Always inspect InnerException for the root cause.","Validate data string format/version before parsing.","Add defensive checks in custom IDataProviderHelper implementations."],"tags":["wrapped-exception","parse-failure","helper"],"backgroundTag":"json-parse-error","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"}