forked from ddrilling/AsbCloudServer
Дмитрий Степанов
a0720e9270
1. Выпилил лишнюю логику 2. Прокинул IConfiguration в HelpPageService 3. Поправил миграции 4. Поправил тесты
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace AsbCloudApp.Exceptions
|
|
{
|
|
/// <summary>
|
|
/// Argument validation fail Exception
|
|
/// </summary>
|
|
public class ArgumentInvalidException : Exception
|
|
{
|
|
/// <summary>
|
|
/// название аргумента
|
|
/// </summary>
|
|
public string ParamName { get; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// конструктор
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <param name="paramName"></param>
|
|
public ArgumentInvalidException(string message, string paramName)
|
|
: base(message)
|
|
{
|
|
ParamName = paramName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// преобразование в объект валидации
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public object ToValidationErrorObject()
|
|
=> MakeValidationError(ParamName, Message);
|
|
|
|
/// <summary>
|
|
/// фабрика объекта валидации
|
|
/// </summary>
|
|
/// <param name="paramName"></param>
|
|
/// <param name="errors"></param>
|
|
/// <returns></returns>
|
|
public static object MakeValidationError(string paramName, params string[] errors)
|
|
=> new
|
|
{
|
|
name = paramName,
|
|
errors,
|
|
};
|
|
}
|
|
}
|