Search in sources :

Example 1 with ResourceNotFoundException

use of me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException in project mecaworks by KadarH.

the class SousFamilleServiceImpl method add.

@Override
public SousFamille add(SousFamille sousFamille) {
    log.info("Service= SousFamilleServiceImpl - calling methode add");
    try {
        sousFamille.setFamille(familleRepo.findById(sousFamille.getFamille().getId()).get());
        sousFamille.setMarque(marqueRepo.findById(sousFamille.getFamille().getId()).get());
        return sousFamilleRepo.save(sousFamille);
    } catch (NoSuchElementException e) {
        log.debug("cannot find famille , failed operation");
        throw new ResourceNotFoundException("L'ajout de la Sous-famille a echouée,famille introuvable ", e);
    } catch (Exception e) {
        log.debug("cannot add SousFamille , failed operation");
        throw new OperationFailedException("L'ajout de la Sous-famille a echouée ", e);
    }
}
Also used : OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) NoSuchElementException(java.util.NoSuchElementException) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)1 OperationFailedException (me.kadarh.mecaworks.service.exceptions.OperationFailedException)1 ResourceNotFoundException (me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException)1