btcpayserver/BTCPayServer.Client/GreenFieldValidationException.cs

27 lines
745 B
C#
Raw Normal View History

2020-06-29 04:44:35 +02:00
using System;
using System.Text;
using BTCPayServer.Client.Models;
namespace BTCPayServer.Client;
public class GreenfieldValidationException : Exception
{
public GreenfieldValidationException(GreenfieldValidationError[] errors) : base(BuildMessage(errors))
{
ValidationErrors = errors;
}
private static string BuildMessage(GreenfieldValidationError[] errors)
{
if (errors == null) throw new ArgumentNullException(nameof(errors));
var builder = new StringBuilder();
foreach (var error in errors)
{
builder.AppendLine($"{error.Path}: {error.Message}");
}
return builder.ToString();
}
public GreenfieldValidationError[] ValidationErrors { get; }
}