forked from ddrilling/AsbCloudServer
29 lines
698 B
C#
29 lines
698 B
C#
using System;
|
|
|
|
namespace AsbCloudApp.Exceptions
|
|
{
|
|
/// <summary>
|
|
/// Argument validation fail Exception
|
|
/// </summary>
|
|
public class ArgumentInvalidException: Exception
|
|
{
|
|
public string ParamName { get; }
|
|
|
|
public ArgumentInvalidException(string message, string paramName = default)
|
|
:base(message)
|
|
{
|
|
ParamName = paramName;
|
|
}
|
|
|
|
public object ToValaidationErrorObject()
|
|
=> MakeValidationError(ParamName, Message);
|
|
|
|
public static object MakeValidationError(string paramName, params string[] errors)
|
|
=> new
|
|
{
|
|
name = paramName,
|
|
errors = errors,
|
|
};
|
|
}
|
|
}
|