38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Reflection;
|
|
|
|
namespace webapi.Exceptions
|
|
{
|
|
[Serializable]
|
|
public class WarningException : Exception
|
|
{
|
|
public WarningException(string message)
|
|
: base(message)
|
|
{
|
|
}
|
|
|
|
public WarningException(string message, Exception ex)
|
|
: base(string.Concat(message, "\r\n", ex.Message, "\r\n", ex.InnerException?.Message), ex.InnerException ?? ex)
|
|
{
|
|
}
|
|
|
|
//public WarningException(ExceptionCodes messageCode)
|
|
// : base($"{messageCode.ToString()}:: {GetEnumDescription(messageCode)}")
|
|
//{
|
|
//}
|
|
|
|
//private static string GetEnumDescription(Enum value)
|
|
//{
|
|
// // Get the Description attribute value for the enum value
|
|
// FieldInfo fi = value.GetType().GetField(value.ToString());
|
|
// DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|
|
|
// if (attributes.Length > 0)
|
|
// return attributes[0].Description;
|
|
// else
|
|
// return value.ToString();
|
|
//}
|
|
}
|
|
}
|