using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using GitHub.Services.Common;
namespace GitHub.DistributedTask.ObjectTemplating
{
[EditorBrowsable(EditorBrowsableState.Never)]
public class TemplateException : VssServiceException
{
public TemplateException(String message)
: base(message)
{
}
public TemplateException(
String message,
Exception innerException)
: base(message, innerException)
{
}
///
/// Initializes an exception from serialized data
///
/// object holding the serialized data
/// context info about the source or destination
protected TemplateException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public class TemplateValidationException : TemplateException
{
public TemplateValidationException()
: this(TemplateStrings.TemplateNotValid())
{
}
public TemplateValidationException(IEnumerable errors)
: this(TemplateStrings.TemplateNotValidWithErrors(string.Join(",", (errors ?? Enumerable.Empty()).Select(e => e.Message))))
{
m_errors = new List(errors ?? Enumerable.Empty());
}
public TemplateValidationException(
String message,
IEnumerable errors)
: this(message)
{
m_errors = new List(errors ?? Enumerable.Empty());
}
public TemplateValidationException(String message)
: base(message)
{
}
public TemplateValidationException(
String message,
Exception innerException)
: base(message, innerException)
{
}
public IList Errors
{
get
{
if (m_errors == null)
{
m_errors = new List();
}
return m_errors;
}
}
///
/// Initializes an exception from serialized data
///
/// object holding the serialized data
/// context info about the source or destination
protected TemplateValidationException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
private List m_errors;
}
}