Instead of using generic Exception type use specific exception. In this case you could use InputMismatchException.