I want to throw an exception to say that we have an invalid email address as I dont want to proceed until we get a valid email address. Is this where I want to do it and if so, how?
void Engine_AfterReadRecord(EngineBase engine, FileHelpers.Events.AfterReadEventArgs<UserInfoFromAd> e){
bool isEmailValid = IsEmailValid(e.Record.Email);
if (!isEmailValid){
//I want to throw exception
}
}
What seems to be the problem? Just throw it:
if (!isEmailValid)
{
throw new InvalidDataException("Email is not valid.");
}