removed logging of wrapped exceptions

This commit is contained in:
Konstantinos Spyrou 2024-09-23 12:12:53 +03:00
parent c5e9c7ea37
commit 5010b8d04f
1 changed files with 8 additions and 13 deletions

View File

@ -6,12 +6,14 @@ import eu.dnetlib.repo.manager.domain.OrderByField;
import eu.dnetlib.repo.manager.domain.OrderByType; import eu.dnetlib.repo.manager.domain.OrderByType;
import eu.dnetlib.repo.manager.domain.Repository; import eu.dnetlib.repo.manager.domain.Repository;
import eu.dnetlib.repo.manager.exception.RepositoryServiceException; import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -177,12 +179,8 @@ public class PiWikServiceImpl implements PiWikService {
emailUtils.sendAdministratorMetricsEnabled(piwikInfo); emailUtils.sendAdministratorMetricsEnabled(piwikInfo);
emailUtils.sendUserMetricsEnabled(piwikInfo); emailUtils.sendUserMetricsEnabled(piwikInfo);
} catch (EmptyResultDataAccessException e) { } catch (DataAccessException e) {
logger.error("Error while approving piwik site: ", e); throw new RepositoryServiceException("Error while approving piwik site: " + e.getMessage(), e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (Exception e) {
logger.error("Error while sending email to administrator or user about the enabling of metrics", e);
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} }
return new ResponseEntity<>("OK", HttpStatus.OK); return new ResponseEntity<>("OK", HttpStatus.OK);
} }
@ -212,14 +210,11 @@ public class PiWikServiceImpl implements PiWikService {
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo); emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
emailUtils.sendUserRequestToEnableMetrics(piwikInfo); emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
logger.error("Error while creating piwikScript URL", uee); throw new RepositoryServiceException("Error while creating piwikScript URL", uee, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (IOException ioe) { } catch (IOException ioe) {
logger.error("Error while creating piwik site", ioe); throw new RepositoryServiceException("Error while creating piwik site", ioe, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); } catch (ResourceNotFoundException e) {
} catch (Exception e) { throw new RepositoryServiceException("Repository with id '" + piwikInfo.getRepositoryId() + "' was not found.", e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
logger.error("Error while sending email to administrator or user about the request to enable metrics", e);
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} }
return piwikInfo; return piwikInfo;
} }