Skip to content

Commit

Permalink
fix: handle cases where one failed brreg fetch broke all
Browse files Browse the repository at this point in the history
  • Loading branch information
SondreJDigdir committed Nov 20, 2024
1 parent 5278320 commit 471dde3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Dan.Plugin.Tilda/Tilda.cs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,24 @@ private async Task<List<EvidenceValue>> GetEvidenceValuesTilsynsRapportAllAsync(
}
}

await Task.WhenAll(taskList);
var taskResult = Task.WhenAll(taskList);
try
{
await taskResult;
}
catch (Exception e)

Check warning on line 828 in src/Dan.Plugin.Tilda/Tilda.cs

View workflow job for this annotation

GitHub Actions / run / build

The variable 'e' is declared but never used

Check warning on line 828 in src/Dan.Plugin.Tilda/Tilda.cs

View workflow job for this annotation

GitHub Actions / run / build

The variable 'e' is declared but never used
{
// Don't want one failed fetch to break the listing of the rest of the orgs
if (taskResult.IsFaulted)
{
var failedTasks = taskList.Where(task => task.IsFaulted).ToList();
foreach (var task in failedTasks)
{
_logger.LogError(task.Exception, task.Exception?.Message);
}
taskList = taskList.Where(task => !task.IsFaulted).ToList();
}
}

taskList = taskList
.Where(task => task.Result is not null)
Expand Down

0 comments on commit 471dde3

Please sign in to comment.