#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 errors) : this(WorkflowStrings.WorkflowNotValidWithErrors(string.Join(" ", (errors ?? Enumerable.Empty()).Take(ErrorCount).Select(e => e.Message)))) { m_errors = new List(errors ?? Enumerable.Empty()); } public WorkflowValidationException(String message) : base(message) { } public WorkflowValidationException( String message, Exception innerException) : base(message, innerException) { } internal IReadOnlyList Errors => (m_errors ?? new List()).AsReadOnly(); private List? m_errors; /// /// Previously set to 2 when there were UI limitations. /// Setting this to 10 to increase the number of errors returned from parser. /// private const int ErrorCount = 10; } }