If email address already exists then throw an exception with a message("message:"User with "+tempEmailId+" already exists"). I don't get my exception message when I test in postman. Can you please help me ? Where is the issue? 
Controller class:
@RestController
public class RegistrationController {
@Autowired
private RegistrationService service;
@PostMapping("/registeruser")
public User registerUser(@RequestBody User user) throws Exception {
String tempEmailId = user.getEmailId();
if(tempEmailId !=null && !"".equals(tempEmailId)) {
User userObject = service.fetchUserByEmailId(tempEmailId);
if(userObject!=null) {
throw new Exception("User with "+tempEmailId+" is already exist");
}
}
User userObject = null;
userObject = service.saveUser(user);
return userObject;
}
}
Repository:
public interface RegistrationRepository extends JpaRepository<User, Integer> {
public User findByEmailId(String emailId); // Here we declare
}
Service:
@Service
public class RegistrationService {
@Autowired
private RegistrationRepository repo;
public User saveUser(User user) {
return repo.save(user);
}
public User fetchUserByEmailId(String email) {
return repo.findByEmailId(email);
}
}