egametang/ET · warning · Exception

text={2}, index={0}, chr='{1}', 0-9的数字或'}}'

Error message

text={2}, index={0}, chr='{1}', 0-9的数字或'}}'

What it means

StrUtil.GetStrChunk error case 3: while reading the numeric index (ReadIndex state), the parser expects more digits 0-9 or the closing '}'. Any other character after the index digits triggers this. Only thrown when throwError=true.

Source

Thrown at Packages/cn.etetet.packagemanager/Editor/Tools/StrUtil_StrChunk.cs:183

                        break;
                }

                //处理错误
                if (throwError && throwErrId > -1)
                {
                    switch (throwErrId)
                    {
                        case 0:
                            throw new Exception(string.Format("text={3}, index={0}, chr='{1}':此处只能出现'{2}'", i, c,
                                                              lastChar, value));
                        case 1:
                            throw new Exception(string.Format("text={2}, index={0}, chr='{1}', 此处只能出现小写英文字符", i, c,
                                                              value));
                        case 2:
                            throw new Exception(string.Format("text={2}, index={0}, chr='{1}', 此处只能出现小写英文或1-9的数字", i, c,
                                                              value));
                        case 3:
                            throw new Exception(string.Format("text={2}, index={0}, chr='{1}', 0-9的数字或'}}'", i, c,
                                                              value));
                    }
                }

                lastChar = c;
            }

            //结尾处理
            if (state != ReadChunkState.ReadText)
            {
                if (throwError)
                {
                    throw new Exception("没有正确结束, state=" + state.ToString());
                }

                sb.Append(keySb.ToString()).Append(indexSb.ToString());
            }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure the index is pure digits followed immediately by '}', e.g. '{key123}'.
  2. Close every placeholder with '}' and remove stray characters.
  3. Use throwError=false tolerant mode to find the exact location.

Example fix

// before
var chunks = StrUtil.GetStrChunk("{key1a}", throwError: true);

// after
var chunks = StrUtil.GetStrChunk("{key1}", throwError: true);
Defensive patterns

Strategy: validation

Validate before calling

StrUtil.GetStrChunk(template, throwError: false);

Try / catch

try { chunks = StrUtil.GetStrChunk(tpl, throwError: true); }
catch (Exception) { chunks = StrUtil.GetStrChunk(tpl, throwError: false); }

Prevention

When it happens

Trigger: A placeholder like '{key1a}' (letter after index), '{key1 }' (space before close), '{key1_' (symbol), or a missing closing brace with trailing junk.

Common situations: Typo in the index portion; missing closing brace; template imported with different delimiter conventions.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/d46c1483b1404ac1. Report an issue: GitHub.