Discuss Regular expressions and exceptions in the Java Help forum on Dev Shed. Regular expressions and exceptions Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
Time spent in forums: 2 h 30 m 50 sec
Reputation Power: 0
Regular expressions and exceptions
I am trying to validate a phone number and a postal code with regular expressions and using a class exception. I would like to confirm that my regular expression are well done and for my class exception I would like to bring the wrong phone number or postal code (depending on the exception) that the user has enter and a message indicating that is invalid (in the exception class) but I don't how. I will appreciate all the comments and help.
Customer class code:
public void setPhoneNumber(String phoneNumber) throws InvalidPhoneNumberException
throw new InvalidPhoneNumberException();