/// <summary> /// Gets a message due to the reason. /// </summary> /// <param name="reason">The reason.</param> /// <returns>The message.</returns> protected static string GetMessage(WrongEmailReason reason) { string result; switch (reason) { case WrongEmailReason.NoAt: result = "@ is missing"; break; case WrongEmailReason.SLDWrong: result = "The second level domain is wrong"; break; case WrongEmailReason.TLDWrong: result = "The first level domain is wrong"; break; case WrongEmailReason.OK: default: result = "No reason."; break; } return(result); }
/// <summary> /// Constructor with an email adress and a reason for the exception. /// </summary> /// <param name="eMailAdress">The email adress with something wrong.</param> /// <param name="reason">The reason for the exception.</param> public WrongEmailException(IEMailAdress eMailAdress, WrongEmailReason reason) : base(GetMessage(reason), eMailAdress) { Reason = reason; }