2022-01-18 11:04:15 +05:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Exceptions
|
|
|
|
|
{
|
2022-02-12 11:28:16 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Argument validation fail Exception
|
|
|
|
|
/// </summary>
|
2022-04-11 18:00:34 +05:00
|
|
|
|
public class ArgumentInvalidException : Exception
|
2022-01-18 11:04:15 +05:00
|
|
|
|
{
|
|
|
|
|
public string ParamName { get; }
|
|
|
|
|
|
|
|
|
|
public ArgumentInvalidException(string message, string paramName = default)
|
2022-04-11 18:00:34 +05:00
|
|
|
|
: base(message)
|
2022-01-18 11:04:15 +05:00
|
|
|
|
{
|
|
|
|
|
ParamName = paramName;
|
|
|
|
|
}
|
2022-02-12 11:28:16 +05:00
|
|
|
|
|
|
|
|
|
public object ToValaidationErrorObject()
|
|
|
|
|
=> MakeValidationError(ParamName, Message);
|
|
|
|
|
|
|
|
|
|
public static object MakeValidationError(string paramName, params string[] errors)
|
|
|
|
|
=> new
|
|
|
|
|
{
|
|
|
|
|
name = paramName,
|
|
|
|
|
errors = errors,
|
|
|
|
|
};
|
2022-01-18 11:04:15 +05:00
|
|
|
|
}
|
|
|
|
|
}
|