Skip to content

Commit 6a2e0d8

Browse files
authored
Print better error message when detecting exit code (#760)
Unfortunately, we cannot retry copying the system log as the original path is already gone.
1 parent 924d4a5 commit 6a2e0d8

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Microsoft.DotNet.XHarness.Apple/ExitCodeDetector.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.IO;
57
using System.Linq;
68
using System.Text.RegularExpressions;
79
using Microsoft.DotNet.XHarness.Common.Logging;
@@ -18,7 +20,18 @@ public abstract class ExitCodeDetector : IExitCodeDetector
1820
{
1921
public int? DetectExitCode(AppBundleInformation appBundleInfo, IReadableLog systemLog)
2022
{
21-
using var reader = systemLog.GetReader();
23+
StreamReader reader;
24+
25+
try
26+
{
27+
reader = systemLog.GetReader();
28+
}
29+
catch (FileNotFoundException e)
30+
{
31+
throw new Exception("Failed to detect application's exit code. The system log was empty / not found at " + e.FileName);
32+
}
33+
34+
using (reader)
2235
while (!reader.EndOfStream)
2336
{
2437
var line = reader.ReadLine();

0 commit comments

Comments
 (0)