Skip to content

Commit

Permalink
Aggregate all of the exceptions
Browse files Browse the repository at this point in the history
Instead of throwing the first exception, throw an aggregation of all of them.
  • Loading branch information
ranma42 committed Jul 2, 2024
1 parent 6b67e70 commit 57ecfca
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ private void AssertBaseline(
Directory.CreateDirectory(baselinesDirectory);

var shouldRewrite = Environment.GetEnvironmentVariable("EF_TEST_REWRITE_BASELINES")?.ToUpper() is "1" or "TRUE";
List<(string Path, Exception Exception)> exceptions = [];
List<Exception> exceptions = [];
foreach (var file in scaffoldedFiles)
{
var fullFilePath = Path.Combine(baselinesDirectory, file.Path);
Expand All @@ -1529,13 +1529,13 @@ private void AssertBaseline(
File.WriteAllText(fullFilePath, file.Code);
}

exceptions.Add((file.Path, ex));
exceptions.Add(new Exception($"Difference found in {file.Path}", ex));
}
}

foreach (var (path, ex) in exceptions)
if (exceptions.Count > 0)
{
throw new Exception($"Difference found in {path}", ex);
throw new AggregateException($"Differences found in {exceptions.Count} files", exceptions);
}
}
}

0 comments on commit 57ecfca

Please sign in to comment.