{"record":{"id":"eacde7cc841e0613","repo":"studyzy/imewlconverter","slug":"error-eacde7","errorCode":null,"errorMessage":"找不到拼音","messagePattern":"找不到拼音","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/ImeWlConverter.Core/Helpers/ZhuyinHelper.cs","lineNumber":70,"sourceCode":"                    var arr = line.Split('\\t');\n\n                    var zhuyinCode = arr[0];\n                    var pinyin = arr[1];\n\n                    if (!pinyinDic.ContainsKey(zhuyinCode))\n                        pinyinDic.Add(zhuyinCode, pinyin);\n                    else\n                        Debug.WriteLine(pinyin + \" mapping more than 1 pinyin\");\n                }\n            }\n\n            return pinyinDic;\n        }\n    }\n\n    public static string? GetZhuyin(string pinyin)\n    {\n        if (string.IsNullOrEmpty(pinyin)) throw new Exception(\"找不到拼音\");\n        var yindiao = 10;\n        if (regex.IsMatch(pinyin))\n        {\n            yindiao = Convert.ToInt32(pinyin[pinyin.Length - 1].ToString());\n            pinyin = pinyin.Substring(0, pinyin.Length - 1);\n        }\n\n        if (!ZhuyinDic.ContainsKey(pinyin))\n        {\n            Debug.WriteLine(\"Can not find zhuyin by pinyin=\" + pinyin);\n            return null;\n        }\n\n        var zy = ZhuyinDic[pinyin] + GetYindiaoZhuyin(yindiao);\n        Debug.WriteLine(\"Pinyin:\" + pinyin + \",Zhuyin:\" + zy);\n        return zy;\n    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/studyzy/imewlconverter/blob/16744a12ed5064896cf39095163e44b367aaada1/src/ImeWlConverter.Core/Helpers/ZhuyinHelper.cs#L52-L88","documentation":"ZhuyinHelper.GetZhuyin(string) converts a pinyin syllable into Bopomofo (注音). Identical guard pattern to Chaoyin (error [0]): it throws this bare Exception ONLY for null/empty pinyin input; it returns null (not throws) for a valid-but-unmapped pinyin. So this throw means the caller passed no pinyin, not an unknown one.","triggerScenarios":"Calling ZhuyinHelper.GetZhuyin(null) or GetZhuyin(\"\"); or indirectly via GetZhuyin(IList<string>) (line 92) when the list contains an empty pinyin string.","commonSituations":"Zhuyin code generation on a word whose pinyin could not be resolved upstream, so an empty pinyin was passed in; an importer emitted blank pinyin codes that reach the zhuyin generator.","solutions":["Filter empty/whitespace strings out of the pinyin list before calling zhuyin generation.","Guard each pinyin with string.IsNullOrEmpty(p) and skip when blank.","Fix upstream pinyin resolution so empty pinyins never reach the generator."],"exampleFix":"// before\nvar zy = ZhuyinHelper.GetZhuyin(p);\n// after\nif (string.IsNullOrEmpty(p)) continue;\nvar zy = ZhuyinHelper.GetZhuyin(p);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(pinyin)) continue;\nvar zy = ZhuyinHelper.GetZhuyin(pinyin);","typeGuard":null,"tryCatchPattern":"try { var zy = ZhuyinHelper.GetZhuyin(p); }\ncatch (Exception ex) when (ex.Message == \"找不到拼音\") { /* skip empty pinyin */ }","preventionTips":["Never pass an empty/null pinyin to a tone or script conversion helper.","Filter empty strings out of pinyin lists before zhuyin generation.","Resolve pinyin upstream so blanks never reach the generator."],"tags":["zhuyin","pinyin","argument","validation"],"backgroundTag":null,"analyzedSha":"16744a12ed5064896cf39095163e44b367aaada1","analyzedAt":"2026-08-13T19:53:09.031Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}