I'm a bit confused on how to handle the error that my trigger generates in the database. In the future, I plan to add the text of this error to the page on which it was processed. IDEA writes that "Exception 'java.sql.SQLException' is never thrown in the corresponding try block"
@PostMapping("/register")
public String addNewUser(User user, Details details) {
user.setPassword(passwordEncoder.encode(user.getPassword()));
user.setRole(Role.USER);
details.setUser(user);
user.setDetails(details);
try {
userRepository.save(user);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
return "redirect:/";
}