{"record":{"id":"b5f7a600dc00a7d2","repo":"babalae/better-genshin-impact","slug":"error-b5f7a6","errorCode":null,"errorMessage":"和弦缺少右括号","messagePattern":"和弦缺少右括号","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/GameTask/Music/Service/MusicScoreParser.cs","lineNumber":292,"sourceCode":"    private static List<YuanQinToken> ParseYuanQinTokens(string sheet)\n    {\n        var tokens = new List<YuanQinToken>();\n        var index = 0;\n        while (index < sheet.Length)\n        {\n            if (sheet[index] == '|')\n            {\n                index++;\n                continue;\n            }\n\n            string keys;\n            if (sheet[index] == '(')\n            {\n                var end = sheet.IndexOf(')', index + 1);\n                if (end < 0)\n                {\n                    throw new FormatException(\"和弦缺少右括号\");\n                }\n\n                keys = sheet[(index + 1)..end];\n                index = end + 1;\n            }\n            else\n            {\n                keys = sheet[index].ToString();\n                index++;\n            }\n\n            if (index >= sheet.Length || sheet[index] != '[')\n            {\n                throw new FormatException($\"音符 {keys} 缺少时值\");\n            }\n\n            var bracketEnd = sheet.IndexOf(']', index + 1);\n            if (bracketEnd < 0)","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Music/Service/MusicScoreParser.cs#L274-L310","documentation":"Thrown by MusicScoreParser.ParseYuanQinTokens(string) when a chord is opened with '(' but no matching ')' is found in the remaining sheet string. The method uses sheet.IndexOf(')', index + 1) and throws if the result is -1 (no closing parenthesis).","triggerScenarios":"A yuanqin sheet string containing '(' without a subsequent ')'. For example, '(QW[1]' where the closing ')' was omitted.","commonSituations":"Manual score authoring error; truncated sheet; conversion tool that fails to balance parentheses.","solutions":["Find the unclosed '(' in the sheet string and add the matching ')'.","Use a sheet syntax validator that checks bracket/parenthesis balance before parsing.","Check the PerformanceScore.Error property for the position context."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check parenthesis balance before parsing\nint open = sheet.Count(c => c == '(');\nint close = sheet.Count(c => c == ')');\nif (open != close) { logger.LogError(\"括号不匹配：{Open} 个 '(' vs {Close} 个 ')'\", open, close); }","typeGuard":null,"tryCatchPattern":"var score = await parser.ParseAsync(path, rootFolder, ct);\nif (!string.IsNullOrEmpty(score.Error)) { logger.LogWarning(score.Error); }","preventionTips":["Balance-check parentheses in the sheet string.","Use a linter or validator for yuanqin sheet syntax.","Cross-reference with example scores."],"tags":["music","yuanqin","format-exception","score-syntax","user-content"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}