{"record":{"id":"3ac6c35f795d9627","repo":"egametang/ET","slug":"text-3-index-0-chr-1-2","errorCode":null,"errorMessage":"text={3}, index={0}, chr='{1}'：此处只能出现'{2}'","messagePattern":"text=(.+?), index=(.+?), chr='(.+?)'：此处只能出现'(.+?)'","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"Packages/cn.etetet.packagemanager/Editor/Tools/StrUtil_StrChunk.cs","lineNumber":174,"sourceCode":"                            sb.Append(c);\n                        }\n                        else\n                        {\n                            throwErrId = 0;\n                            sb.Append(lastChar).Append(c);\n                        }\n\n                        state = ReadChunkState.ReadText;\n                        break;\n                }\n\n                //处理错误\n                if (throwError && throwErrId > -1)\n                {\n                    switch (throwErrId)\n                    {\n                        case 0:\n                            throw new Exception(string.Format(\"text={3}, index={0}, chr='{1}'：此处只能出现'{2}'\", i, c,\n                                                              lastChar, value));\n                        case 1:\n                            throw new Exception(string.Format(\"text={2}, index={0}, chr='{1}', 此处只能出现小写英文字符\", i, c,\n                                                              value));\n                        case 2:\n                            throw new Exception(string.Format(\"text={2}, index={0}, chr='{1}', 此处只能出现小写英文或1-9的数字\", i, c,\n                                                              value));\n                        case 3:\n                            throw new Exception(string.Format(\"text={2}, index={0}, chr='{1}', 0-9的数字或'}}'\", i, c,\n                                                              value));\n                    }\n                }\n\n                lastChar = c;\n            }\n\n            //结尾处理\n            if (state != ReadChunkState.ReadText)","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.packagemanager/Editor/Tools/StrUtil_StrChunk.cs#L156-L192","documentation":"StrUtil.GetStrChunk parses placeholder syntax like {key1} in template strings. Error case 0 fires in the Escape state when a closing brace '}' is followed by a character that is not the same as the preceding one — i.e. a malformed escape sequence. Only thrown when throwError=true.","triggerScenarios":"A template string contains a lone '}' that is not part of a {key} placeholder and is not a valid escape ('}}' for a literal '}'). For example \"text}x\" triggers it because '}' enters Escape state and the next char differs.","commonSituations":"Localization/template strings with stray braces from manual editing; copy-pasting content that contains regex or code braces into a template field; format strings imported from external sources.","solutions":["Fix the template: escape a literal '}' as '}}' and a literal '{' as '{{'.","Re-run GetStrChunk with throwError=false to get fault-tolerant parsing and inspect where it diverges.","Audit all template/localization strings for unbalanced or stray braces."],"exampleFix":"// before — stray brace\nvar chunks = StrUtil.GetStrChunk(\"hello}world\", throwError: true);\n\n// after — escaped\nvar chunks = StrUtil.GetStrChunk(\"hello}}world\", throwError: true);","handlingStrategy":"validation","validationCode":"StrUtil.GetStrChunk(template, throwError: false); // tolerant first pass to detect issues","typeGuard":null,"tryCatchPattern":"try { chunks = StrUtil.GetStrChunk(tpl, throwError: true); }\ncatch (Exception ex) { Log.Error($\"bad template: {tpl}, {ex.Message}\"); chunks = StrUtil.GetStrChunk(tpl, throwError: false); }","preventionTips":["Escape literal braces as {{ and }} in templates.","Validate templates at import time, not at runtime.","Use throwError=false for user-facing parsing, true for authoring tooling."],"tags":["packagemanager","editor","parsing","string-template"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}