Skip to content

Commit

Permalink
Print better error message when detecting exit code (#760)
Browse files Browse the repository at this point in the history
Unfortunately, we cannot retry copying the system log as the original path is already gone.
  • Loading branch information
premun authored Nov 8, 2021
1 parent 924d4a5 commit 6a2e0d8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Microsoft.DotNet.XHarness.Apple/ExitCodeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.DotNet.XHarness.Common.Logging;
Expand All @@ -18,7 +20,18 @@ public abstract class ExitCodeDetector : IExitCodeDetector
{
public int? DetectExitCode(AppBundleInformation appBundleInfo, IReadableLog systemLog)
{
using var reader = systemLog.GetReader();
StreamReader reader;

try
{
reader = systemLog.GetReader();
}
catch (FileNotFoundException e)
{
throw new Exception("Failed to detect application's exit code. The system log was empty / not found at " + e.FileName);
}

using (reader)
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
Expand Down

0 comments on commit 6a2e0d8

Please sign in to comment.