improved error messages #33

This commit is contained in:
irongut
2022-02-19 18:02:02 +00:00
parent 4c876916c9
commit 1699cd4b65
+8 -5
View File
@@ -37,7 +37,7 @@ namespace CodeCoverageSummary
{ {
if (!File.Exists(file)) if (!File.Exists(file))
{ {
Console.WriteLine($"Error: Code coverage file not found - {file}."); Console.WriteLine($"Error: Coverage file not found - {file}.");
return -2; // error return -2; // error
} }
} }
@@ -46,7 +46,7 @@ namespace CodeCoverageSummary
CodeSummary summary = new(); CodeSummary summary = new();
foreach (var file in matchingFiles) foreach (var file in matchingFiles)
{ {
Console.WriteLine($"Code Coverage File: {file}"); Console.WriteLine($"Coverage File: {file}");
summary = ParseTestResults(file, summary); summary = ParseTestResults(file, summary);
} }
@@ -160,7 +160,7 @@ namespace CodeCoverageSummary
select item; select item;
if (!lineR.Any()) if (!lineR.Any())
throw new Exception("Summary Line Rate not found"); throw new Exception("Overall line rate not found");
summary.LineRate += double.Parse(lineR.First().Value); summary.LineRate += double.Parse(lineR.First().Value);
@@ -169,7 +169,7 @@ namespace CodeCoverageSummary
select item; select item;
if (!linesCovered.Any()) if (!linesCovered.Any())
throw new Exception("Summary Lines Covered not found"); throw new Exception("Overall lines covered not found");
summary.LinesCovered += int.Parse(linesCovered.First().Value); summary.LinesCovered += int.Parse(linesCovered.First().Value);
@@ -178,7 +178,7 @@ namespace CodeCoverageSummary
select item; select item;
if (!linesValid.Any()) if (!linesValid.Any())
throw new Exception("Summary Lines Valid not found"); throw new Exception("Overall lines valid not found");
summary.LinesValid += int.Parse(linesValid.First().Value); summary.LinesValid += int.Parse(linesValid.First().Value);
@@ -209,6 +209,9 @@ namespace CodeCoverageSummary
var packages = from item in coverage.Descendants("package") var packages = from item in coverage.Descendants("package")
select item; select item;
if (!packages.Any())
throw new Exception("No package data found");
int i = 1; int i = 1;
foreach (var item in packages) foreach (var item in packages)
{ {