Skip to content

Commit 1699cd4

Browse files
committed
improved error messages #33
1 parent 4c87691 commit 1699cd4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/CodeCoverageSummary/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static int Main(string[] args)
3737
{
3838
if (!File.Exists(file))
3939
{
40-
Console.WriteLine($"Error: Code coverage file not found - {file}.");
40+
Console.WriteLine($"Error: Coverage file not found - {file}.");
4141
return -2; // error
4242
}
4343
}
@@ -46,7 +46,7 @@ private static int Main(string[] args)
4646
CodeSummary summary = new();
4747
foreach (var file in matchingFiles)
4848
{
49-
Console.WriteLine($"Code Coverage File: {file}");
49+
Console.WriteLine($"Coverage File: {file}");
5050
summary = ParseTestResults(file, summary);
5151
}
5252

@@ -160,7 +160,7 @@ private static CodeSummary ParseTestResults(string filename, CodeSummary summary
160160
select item;
161161

162162
if (!lineR.Any())
163-
throw new Exception("Summary Line Rate not found");
163+
throw new Exception("Overall line rate not found");
164164

165165
summary.LineRate += double.Parse(lineR.First().Value);
166166

@@ -169,7 +169,7 @@ private static CodeSummary ParseTestResults(string filename, CodeSummary summary
169169
select item;
170170

171171
if (!linesCovered.Any())
172-
throw new Exception("Summary Lines Covered not found");
172+
throw new Exception("Overall lines covered not found");
173173

174174
summary.LinesCovered += int.Parse(linesCovered.First().Value);
175175

@@ -178,7 +178,7 @@ private static CodeSummary ParseTestResults(string filename, CodeSummary summary
178178
select item;
179179

180180
if (!linesValid.Any())
181-
throw new Exception("Summary Lines Valid not found");
181+
throw new Exception("Overall lines valid not found");
182182

183183
summary.LinesValid += int.Parse(linesValid.First().Value);
184184

@@ -209,6 +209,9 @@ private static CodeSummary ParseTestResults(string filename, CodeSummary summary
209209
var packages = from item in coverage.Descendants("package")
210210
select item;
211211

212+
if (!packages.Any())
213+
throw new Exception("No package data found");
214+
212215
int i = 1;
213216
foreach (var item in packages)
214217
{

0 commit comments

Comments
 (0)