fix connectivity check cancellation

This commit is contained in:
bluepilledgreat 2024-10-16 18:44:41 +01:00
parent 9edd5fe2da
commit d74511b334

View File

@ -86,7 +86,7 @@
if (finishedTask.IsFaulted) if (finishedTask.IsFaulted)
exceptions.Add(finishedTask.Exception!.InnerException!); exceptions.Add(finishedTask.Exception!.InnerException!);
else else if (!finishedTask.IsCanceled)
BaseUrl = finishedTask.Result; BaseUrl = finishedTask.Result;
} }
@ -94,7 +94,11 @@
tokenSource.Cancel(); tokenSource.Cancel();
if (string.IsNullOrEmpty(BaseUrl)) if (string.IsNullOrEmpty(BaseUrl))
return exceptions[0]; {
if (exceptions.Any())
return exceptions[0];
return new TaskCanceledException("All tasks have been cancelled"); // we can't add TaskCanceledExceptions to the list
}
App.Logger.WriteLine(LOG_IDENT, $"Got {BaseUrl} as the optimal base URL"); App.Logger.WriteLine(LOG_IDENT, $"Got {BaseUrl} as the optimal base URL");