// Copyright Epic Games, Inc. All Rights Reserved. using EpicGames.Core; using Microsoft.Extensions.Logging; using System.Text.RegularExpressions; #nullable enable namespace AutomationUtils.Matchers { /// /// Matches a generic C# exception /// class ExceptionEventMatcher : ILogEventMatcher { static readonly Regex s_pattern = new Regex(@"^\s*Unhandled Exception: "); static readonly Regex s_atPattern = new Regex(@"^\s*at "); /// 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; } } }