Update UserAccountService.java

Moving the call to addUserAccount method out of condition to check if violations exist.
This commit is contained in:
raviavhad 2021-07-24 13:45:21 +05:30 committed by GitHub
parent 66360a6b31
commit d5399a7677
1 changed files with 3 additions and 8 deletions

View File

@ -30,14 +30,9 @@ public class UserAccountService {
for (ConstraintViolation<UserAccount> constraintViolation : violations) { for (ConstraintViolation<UserAccount> constraintViolation : violations) {
sb.append(constraintViolation.getMessage()); sb.append(constraintViolation.getMessage());
} }
dao.addUserAccount(useraccount);
throw new ConstraintViolationException("Error occurred: " + sb.toString(), violations); throw new ConstraintViolationException("Error occurred: " + sb.toString(), violations);
} }
dao.addUserAccount(useraccount);
return "Account for " + useraccount.getName() + " Added!"; return "Account for " + useraccount.getName() + " Added!";
} }