Skip to content

Commit

Permalink
added try/catch block in registerUser method
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-chern committed Aug 6, 2023
1 parent a053e1b commit 3b885fe
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/core/basesyntax/UserService.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package core.basesyntax;

public class UserService {
private final PasswordValidator passwordValidator = new PasswordValidator();

public void registerUser(User user) {
//write your code here
try {
passwordValidator.validate(user.getPassword(), user.getRepeatPassword());
saveUser(user);
} catch (PasswordValidationException e) {
System.out.println("Your passwords are incorrect. Try again.");
}
}

public void saveUser(User user) {
Expand Down

0 comments on commit 3b885fe

Please sign in to comment.