Handle exceptions thrown by HttpClient.GetAsync.

This commit is contained in:
Paul Chote
2022-04-23 11:41:25 +01:00
committed by abcdefg30
parent 6c81590b20
commit 0dbd8264b8
4 changed files with 30 additions and 24 deletions

View File

@@ -235,12 +235,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Task.Run(async () =>
{
var client = HttpClientFactory.Create();
var httpResponseMessage = await client.GetAsync(download.MirrorList);
var result = await httpResponseMessage.Content.ReadAsStringAsync();
try
{
var client = HttpClientFactory.Create();
var httpResponseMessage = await client.GetAsync(download.MirrorList);
var result = await httpResponseMessage.Content.ReadAsStringAsync();
var mirrorList = result.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
downloadUrl(mirrorList.Random(new MersenneTwister()));
}