Files
2025-05-18 13:04:45 +08:00

35 lines
842 B
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using Microsoft.Extensions.Logging;
using System.Text.RegularExpressions;
#nullable enable
namespace AutomationUtils.Matchers
{
/// <summary>
/// Matches a generic C# exception
/// </summary>
class ExceptionEventMatcher : ILogEventMatcher
{
static readonly Regex s_pattern = new Regex(@"^\s*Unhandled Exception: ");
static readonly Regex s_atPattern = new Regex(@"^\s*at ");
/// <inheritdoc/>
public LogEventMatch? Match(ILogCursor cursor)
{
if (cursor.IsMatch(s_pattern))
{
LogEventBuilder builder = new LogEventBuilder(cursor);
while(builder.Current.IsMatch(1, s_atPattern))
{
builder.MoveNext();
}
return builder.ToMatch(LogEventPriority.Low, LogLevel.Error, KnownLogEvents.Exception);
}
return null;
}
}
}