Skip to content
Snippets Groups Projects
Commit d97f1c19 authored by Henrik's avatar Henrik
Browse files

fix: improve error message

parent 39cdcb48
No related branches found
No related tags found
No related merge requests found
package no.ntnu.idi.stud.savingsapp.exception.user;
/**
* Exception thrown regarding a user in the system.
*/
public final class UserException extends RuntimeException {
/**
* Constructs a UserException with the default message.
*/
public UserException(String string) {
super(string);
}
}
......@@ -9,6 +9,7 @@ import no.ntnu.idi.stud.savingsapp.bank.service.AccountService;
import no.ntnu.idi.stud.savingsapp.exception.auth.InvalidCredentialsException;
import no.ntnu.idi.stud.savingsapp.exception.user.EmailAlreadyExistsException;
import no.ntnu.idi.stud.savingsapp.exception.user.InvalidPasswordResetTokenException;
import no.ntnu.idi.stud.savingsapp.exception.user.UserException;
import no.ntnu.idi.stud.savingsapp.exception.user.UserNotFoundException;
import no.ntnu.idi.stud.savingsapp.model.BankAccountType;
import no.ntnu.idi.stud.savingsapp.model.user.Feedback;
......@@ -225,8 +226,8 @@ public class UserServiceImpl implements UserService {
try {
return userRepository.save(user);
} catch (DataIntegrityViolationException e) {
log.error("[UserServiceImpl:update] email already exists: {}", user.getId());
throw new EmailAlreadyExistsException();
log.error("[UserServiceImpl:update] data integrity violation: {}", e.getMostSpecificCause().getMessage());
throw new UserException(e.getMostSpecificCause().getMessage());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment