catching email exceptions

This commit is contained in:
Antonis Lempesis 2021-10-18 22:50:25 +00:00
parent c09f7a534e
commit 372091fd42
1 changed files with 8 additions and 7 deletions

View File

@ -486,8 +486,7 @@ LOGGER.debug("json: " + jsonArray);
}
@Override
public Repository addRepository(String datatype,
Repository repository) throws Exception {
public Repository addRepository(String datatype, Repository repository) throws Exception {
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
@ -558,14 +557,16 @@ LOGGER.debug("json: " + jsonArray);
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
emailUtils.sendUserRegistrationEmail(repository, authentication);
emailUtils.sendAdminRegistrationEmail(repository, authentication);
try {
emailUtils.sendUserRegistrationEmail(repository, authentication);
emailUtils.sendAdminRegistrationEmail(repository, authentication);
} catch (Exception e) {
LOGGER.error("Error sending email", e);
}
} else
LOGGER.debug(responseEntity.getBody().toString());
LOGGER.error("Error storing repository: " + responseEntity.getBody().toString());
return repository;
}
@Override