catch errors pulling data from other instances

This commit is contained in:
Gervasio Marchand 2022-12-09 18:19:15 -03:00
parent f38c7ec00d
commit 0c7589c177
No known key found for this signature in database
GPG Key ID: B7736CB188DD0A38

View File

@ -36,14 +36,15 @@ await Parallel.ForEachAsync(sitesTags, parallelOptions, async (st, _) =>
{
var (site, tag) = st;
Console.WriteLine($"Fetching tag #{tag} from {site}");
var response = await client.GetAsync($"https://{site}/tags/{tag}.json");
HttpResponseMessage? response = null;
try
{
response = await client.GetAsync($"https://{site}/tags/{tag}.json");
response.EnsureSuccessStatusCode();
}
catch (Exception e)
{
Console.WriteLine($"Error fetching tag, status code: {response.StatusCode}. Error: {e.Message}");
Console.WriteLine($"Error fetching tag, status code: {response?.StatusCode}. Error: {e.Message}");
return;
}