EllanJiang/GameFramework · error · GameFrameworkException

Data string is invalid.

Error message

Data string is invalid.

What it means

ParseData(string, object) validates that the dataString argument is non-null before delegating to the helper. A null string cannot be parsed, so the provider throws this explicit argument error. Empty strings are allowed; only null is rejected.

Solutions

  1. Ensure the string is loaded and non-null before calling ParseData.
  2. Trace why the upstream source (file, network, resource load) produced null and fix that load.
  3. If null is legitimately possible, check for null and handle it before parsing.

Example fix

// before
string text = LoadText(); // may be null
bool ok = dataProvider.ParseData(text, null);
// after
string text = LoadText();
if (text != null) { bool ok = dataProvider.ParseData(text, null); }
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(dataString)) { /* handle missing data */ }
bool ok = dataProvider.ParseData(dataString, userData);

Type guard

bool IsParseable(string s) => s != null;

Try / catch

try { dataProvider.ParseData(text, null); }
catch (GameFrameworkException e) when (e.Message == "Data string is invalid.") { Log.Error("Parse input was null; check upstream load."); }

Prevention

When it happens

Trigger: Passing null (or an expression evaluating to null) as dataString to ParseData(string) or ParseData(string, object) — e.g. a failed file read or deserialization returned null upstream.

Common situations: Reading config text from a file/WebRequest that failed and returning null into ParseData; a property initialized to null used as the parse input; test harness passing null to check error handling.

Related errors


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

Appendix: source

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

            return ParseData(dataString, null);
        }

        /// <summary>
        /// 解析内容。
        /// </summary>
        /// <param name="dataString">要解析的内容字符串。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>是否解析内容成功。</returns>
        public bool ParseData(string dataString, object userData)
        {
            if (m_DataProviderHelper == null)
            {
                throw new GameFrameworkException("You must set data helper first.");
            }

            if (dataString == null)
            {
                throw new GameFrameworkException("Data string is invalid.");
            }

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

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

        /// <summary>

View on GitHub (pinned to d0c010b051)