added a mechanism to handle form validation(throw an exception)