{"record":{"id":"250942295a277ab8","repo":"babalae/better-genshin-impact","slug":"culturename-json","errorCode":null,"errorMessage":"下载语言文件失败：{cultureName}.json","messagePattern":"下载语言文件失败：(.+?)\\.json","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs","lineNumber":168,"sourceCode":"                    ?? throw new JsonException(\"翻译文件不是有效的 JSON 字典。\");\n                break;\n            }\n            catch (Exception e)\n            {\n                lastError = e;\n                allNotFound = false;\n            }\n        }\n\n        if (bytes == null)\n        {\n            if (allNotFound)\n            {\n                await ThemedMessageBox.WarningAsync($\"语言文件不存在：{cultureName}.json\");\n                return;\n            }\n\n            throw new Exception($\"下载语言文件失败：{cultureName}.json\", lastError);\n        }\n\n        var dir = Global.Absolute(@\"User\\I18n\");\n        Directory.CreateDirectory(dir);\n        var path = Path.Combine(dir, $\"{cultureName}.json\");\n        var tmp = $\"{path}.{Guid.NewGuid():N}.tmp\";\n        await File.WriteAllBytesAsync(tmp, bytes);\n\n        if (File.Exists(path))\n        {\n            File.Replace(tmp, path, null);\n        }\n        else\n        {\n            File.Move(tmp, path);\n        }\n\n        var translator = App.GetService<ITranslationService>() ?? throw new NullReferenceException();","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs#L150-L186","documentation":"Thrown after every mirror URL fails to download and at least one failure was not a clean 404. lastError holds the most recent exception (timeout, TLS, DNS, 5xx, etc.). This is the terminal failure when no language file could be retrieved from any source.","triggerScenarios":"Both the GitHub raw URL and the cnb.cool mirror fail with non-404 errors: network outage, DNS failure, TLS handshake error, 30s timeout, proxy interference, or a 5xx server response.","commonSituations":"No internet connection; corporate firewall blocks raw.githubusercontent.com and cnb.cool; GitHub rate-limiting; transient server errors; misconfigured system proxy.","solutions":["Check network connectivity and retry — both mirrors must fail for this to throw.","Allow the user to configure a custom mirror or proxy for the i18n download.","Retry with exponential backoff across mirrors before giving up, and surface lastError.Message to the user for diagnosis."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!await CheckInternetConnectivityAsync())\n{\n    // warn user before attempting download\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await OnUpdateUiLanguageAsync();\n}\ncatch (Exception ex) when (ex.Message.StartsWith(\"下载语言文件失败\"))\n{\n    await ThemedMessageBox.WarningAsync($\"下载失败：{ex.InnerException?.Message ?? ex.Message}\");\n}","preventionTips":["Provide multiple mirrors and try them in order (already done).","Add retry-with-backoff before giving up on transient network errors.","Let users configure a proxy or custom mirror for restrictive networks."],"tags":["network","i18n","download"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}