Skip to content

Commit ff094e1

Browse files
authored
Merge pull request #5 from Trendyol/fix/foreach-throw-exception
fix: throw one exception
2 parents 6a20af8 + 2f8f95c commit ff094e1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Database/Repositories/Couchbase/CouchbaseMissingEventRepository.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,17 @@ public async Task IncrementRetryCountAsync(IEnumerable<long> ids)
8585

8686
await Task.WhenAll(tasks);
8787

88-
foreach (var task in tasks.Where(task => task.Result.MetaData!.Status != QueryStatus.Success))
88+
ThrowExceptionsForFailedQueries(tasks);
89+
}
90+
91+
private static void ThrowExceptionsForFailedQueries(List<Task<IQueryResult<dynamic>>> tasks)
92+
{
93+
var failedTasks = tasks.Where(task => task.Result.MetaData!.Status != QueryStatus.Success).ToList();
94+
if (failedTasks.Count > 0)
8995
{
90-
throw new CouchbaseQueryFailedException(task.Result.Errors.ToString());
96+
var errors = failedTasks.Select(task => task.Result.Errors.ToString()).ToList();
97+
var joinedErrors = string.Join(" | ", errors);
98+
throw new CouchbaseQueryFailedException(joinedErrors);
9199
}
92100
}
93101

0 commit comments

Comments
 (0)