mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 21:46:33 +00:00
f5e466108a
add ToHash for encryption Key
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System.ComponentModel;
|
|
using Azaion.Common.Extensions;
|
|
|
|
namespace Azaion.Common;
|
|
|
|
public class BusinessException(ExceptionEnum exEnum) : Exception(GetMessage(exEnum))
|
|
{
|
|
private static readonly Dictionary<ExceptionEnum, string> ExceptionDescriptions;
|
|
|
|
static BusinessException()
|
|
{
|
|
ExceptionDescriptions = EnumExtensions.GetDescriptions<ExceptionEnum>();
|
|
}
|
|
|
|
private ExceptionEnum ExceptionEnum { get; set; } = exEnum;
|
|
|
|
public static string GetMessage(ExceptionEnum exEnum) => ExceptionDescriptions.GetValueOrDefault(exEnum) ?? exEnum.ToString();
|
|
}
|
|
|
|
public enum ExceptionEnum
|
|
{
|
|
[Description("No such email found.")]
|
|
NoEmailFound = 10,
|
|
|
|
[Description("Email already exists.")]
|
|
EmailExists = 20,
|
|
|
|
[Description("Passwords do not match.")]
|
|
WrongPassword = 30,
|
|
|
|
[Description("Password should be at least 8 characters.")]
|
|
PasswordLengthIncorrect = 32,
|
|
|
|
EmailLengthIncorrect = 35,
|
|
|
|
WrongEmail = 37,
|
|
|
|
[Description("HardwareInfo mismatch! You are not authorized to access this resource from this hardware.")]
|
|
HardwareIdMismatch = 40,
|
|
|
|
[Description("HardwareInfo should contain information about this hardware.")]
|
|
BadHardware = 45,
|
|
|
|
[Description("Wrong resource file name.")]
|
|
WrongResourceName = 50,
|
|
|
|
[Description("No file provided.")]
|
|
NoFileProvided = 60,
|
|
} |