diff --git a/src/MaaWpfGui/Services/Web/GameDataReportService.cs b/src/MaaWpfGui/Services/Web/GameDataReportService.cs index 3b0fb6c53b..90de62b25d 100644 --- a/src/MaaWpfGui/Services/Web/GameDataReportService.cs +++ b/src/MaaWpfGui/Services/Web/GameDataReportService.cs @@ -73,23 +73,30 @@ namespace MaaWpfGui.Services.Web private static async Task TryPostAsync(string targetUrl, HttpContent content, Dictionary headers) { - int currentBackoff = InitialBackoffMs; - for (int attempt = 1; attempt <= MaxRetryPerDomain; attempt++) + try { - var response = await Instances.HttpService.PostAsync(new(targetUrl), content, headers); - - switch ((int)response.StatusCode) + int currentBackoff = InitialBackoffMs; + for (int attempt = 1; attempt <= MaxRetryPerDomain; attempt++) { - case 200: - return response; - case >= 500 and < 600: - await Task.Delay(currentBackoff); - currentBackoff = (int)(currentBackoff * 1.5); - continue; - default: - return response; + var response = await Instances.HttpService.PostAsync(new(targetUrl), content, headers); + + switch ((int)response.StatusCode) + { + case 200: + return response; + case >= 500 and < 600: + await Task.Delay(currentBackoff); + currentBackoff = (int)(currentBackoff * 1.5); + continue; + default: + return response; + } } } + catch (Exception ex) + { + _logger.Error(ex, "Error during HTTP POST request to {TargetUrl}", targetUrl); + } return null; }