2022-01-18 11:04:15 +05:00
|
|
|
|
using System;
|
2023-10-23 15:54:29 +05:00
|
|
|
|
using System.Collections.Generic;
|
2023-10-23 16:45:49 +05:00
|
|
|
|
using System.Linq;
|
2022-01-18 11:04:15 +05:00
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Exceptions
|
|
|
|
|
{
|
2022-02-12 11:28:16 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Argument validation fail Exception
|
|
|
|
|
/// </summary>
|
2023-06-29 16:31:37 +05:00
|
|
|
|
public class ArgumentInvalidException : Exception
|
2022-01-18 11:04:15 +05:00
|
|
|
|
{
|
2022-06-02 12:35:51 +05:00
|
|
|
|
/// <summary>
|
2023-10-23 16:45:49 +05:00
|
|
|
|
/// словарь с ошибками, где ключ - имя аргумента, а значение - массив из одного сообщения
|
2022-06-02 12:35:51 +05:00
|
|
|
|
/// </summary>
|
2023-10-23 16:45:49 +05:00
|
|
|
|
public IDictionary<string, string[]> ErrorState { get; } = null!;
|
2022-01-18 11:04:15 +05:00
|
|
|
|
|
2022-06-02 12:35:51 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// конструктор
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="paramName"></param>
|
2023-09-29 12:06:46 +05:00
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
public ArgumentInvalidException(string paramName, string message)
|
2022-04-11 18:00:34 +05:00
|
|
|
|
: base(message)
|
2022-01-18 11:04:15 +05:00
|
|
|
|
{
|
2023-10-23 16:45:49 +05:00
|
|
|
|
ErrorState = new Dictionary<string, string[]>() {
|
2023-10-23 15:54:29 +05:00
|
|
|
|
{ paramName, new[]{ message } }
|
|
|
|
|
};
|
2023-10-23 13:43:29 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// конструктор
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="paramsNames"></param>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
public ArgumentInvalidException(string[] paramsNames, string message)
|
|
|
|
|
: base(message)
|
|
|
|
|
{
|
2023-10-23 16:45:49 +05:00
|
|
|
|
ErrorState = paramsNames.ToDictionary(paramName => paramName, item => new[] { message });
|
2022-01-18 11:04:15 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|