Compare updated template evaluator (#4092)

This commit is contained in:
eric sciple
2025-11-07 14:18:52 -06:00
committed by GitHub
parent 53d69ff441
commit b5b7986cd6
188 changed files with 27222 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace GitHub.Actions.WorkflowParser
{
public class WorkflowValidationException : Exception
{
public WorkflowValidationException()
: this(WorkflowStrings.WorkflowNotValid())
{
}
public WorkflowValidationException(IEnumerable<WorkflowValidationError> errors)
: this(WorkflowStrings.WorkflowNotValidWithErrors(string.Join(" ", (errors ?? Enumerable.Empty<WorkflowValidationError>()).Take(ErrorCount).Select(e => e.Message))))
{
m_errors = new List<WorkflowValidationError>(errors ?? Enumerable.Empty<WorkflowValidationError>());
}
public WorkflowValidationException(String message)
: base(message)
{
}
public WorkflowValidationException(
String message,
Exception innerException)
: base(message, innerException)
{
}
internal IReadOnlyList<WorkflowValidationError> Errors => (m_errors ?? new List<WorkflowValidationError>()).AsReadOnly();
private List<WorkflowValidationError>? m_errors;
/// <summary>
/// Previously set to 2 when there were UI limitations.
/// Setting this to 10 to increase the number of errors returned from parser.
/// </summary>
private const int ErrorCount = 10;
}
}