egametang/ET · warning · Exception

text={2}, index={0}, chr='{1}', 此处只能出现小写英文或1-9的数字

Error message

text={2}, index={0}, chr='{1}', 此处只能出现小写英文或1-9的数字

What it means

StrUtil.GetStrChunk error case 2: while reading a key name (ReadKey state), after the initial lowercase letters, the parser expects either more lowercase letters (a-z) or a digit 1-9 to start the index. Any other character (e.g. uppercase, symbol, space) triggers this. Only thrown when throwError=true.

Source

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

                        }

                        state = ReadChunkState.ReadText;
                        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());
                }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Use only lowercase letters for the key portion and start the index with 1-9, e.g. '{keyname1}'.
  2. Remove separators/uppercase from placeholder keys.
  3. Validate templates with throwError=false first to locate the bad placeholder.

Example fix

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

// after
var chunks = StrUtil.GetStrChunk("{player1}", 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 '{key_1}' (underscore), '{key-1}' (hyphen), '{key 1}' (space), or '{keyA1}' (uppercase mid-key).

Common situations: Keys with separators or mixed case that the grammar does not allow; templates authored with a different naming convention.

Related errors


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