babalae/better-genshin-impact · error · Exception
下载语言文件失败: .json
Error message
下载语言文件失败:{cultureName}.json What it means
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.
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.
Defensive patterns
Strategy: retry
Validate before calling
if (!await CheckInternetConnectivityAsync())
{
// warn user before attempting download
} Try / catch
try
{
await OnUpdateUiLanguageAsync();
}
catch (Exception ex) when (ex.Message.StartsWith("下载语言文件失败"))
{
await ThemedMessageBox.WarningAsync($"下载失败:{ex.InnerException?.Message ?? ex.Message}");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: No internet connection; corporate firewall blocks raw.githubusercontent.com and cnb.cool; GitHub rate-limiting; transient server errors; misconfigured system proxy.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/250942295a277ab8.
Report an issue: GitHub.
Appendix: source
Thrown at BetterGenshinImpact/ViewModel/Pages/CommonSettingsPageViewModel.cs:168
?? throw new JsonException("翻译文件不是有效的 JSON 字典。");
break;
}
catch (Exception e)
{
lastError = e;
allNotFound = false;
}
}
if (bytes == null)
{
if (allNotFound)
{
await ThemedMessageBox.WarningAsync($"语言文件不存在:{cultureName}.json");
return;
}
throw new Exception($"下载语言文件失败:{cultureName}.json", lastError);
}
var dir = Global.Absolute(@"User\I18n");
Directory.CreateDirectory(dir);
var path = Path.Combine(dir, $"{cultureName}.json");
var tmp = $"{path}.{Guid.NewGuid():N}.tmp";
await File.WriteAllBytesAsync(tmp, bytes);
if (File.Exists(path))
{
File.Replace(tmp, path, null);
}
else
{
File.Move(tmp, path);
}
var translator = App.GetService<ITranslationService>() ?? throw new NullReferenceException();View on GitHub (pinned to a7cb36712d)