Commit d24b6b04 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Exceptions: Ajouts de quelques catch.

parent b79fe203
Loading
Loading
Loading
Loading
Loading
+36 −0
Changes for module/Application/src/Application/Service/These/TheseService.php: 36 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ use Application\Service\Notification\NotificationServiceAwareTrait;
use Application\Service\UserContextService;
use Application\Service\Validation\ValidationServiceAwareTrait;
use Application\Service\Variable\VariableServiceAwareTrait;
use Doctrine\DBAL\DBALException;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use UnicaenApp\Exception\RuntimeException;
@@ -108,6 +110,8 @@ class TheseService extends BaseService
    }

    /**
     * Recherche de thèses à l'aide de la vue matérialisée MV_RECHERCHE_THESE.
     *
     * @param string  $text
     * @param integer $limit
     *
@@ -144,7 +148,11 @@ class TheseService extends BaseService
        $orc = implode(' OR ', $orc);
        $sql .= ' AND (' . $orc . ') ';

        try {
            $stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
        } catch (DBALException $e) {
            throw new RuntimeException("Erreur rencontrée lors de la requête", null, $e);
        }

        $theses = [];
        while ($r = $stmt->fetch()) {
@@ -170,7 +178,11 @@ class TheseService extends BaseService
            $this->entityManager->persist($metadonnee);
        }

        try {
            $this->entityManager->flush($metadonnee);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }
    }

    /**
@@ -186,7 +198,11 @@ class TheseService extends BaseService
            $this->entityManager->persist($attestation);
        }

        try {
            $this->entityManager->flush($attestation);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }
    }

    /**
@@ -209,7 +225,11 @@ class TheseService extends BaseService
            $this->entityManager->remove($attestation);
        }

        try {
            $this->entityManager->flush($attestation);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }
    }

    /**
@@ -225,7 +245,11 @@ class TheseService extends BaseService
            $this->entityManager->persist($mel);
        }

        try {
            $this->entityManager->flush($mel);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }
    }

    /**
@@ -248,7 +272,11 @@ class TheseService extends BaseService
            $this->entityManager->remove($diffusion);
        }

        try {
            $this->entityManager->flush($diffusion);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }
    }

    /**
@@ -280,7 +308,11 @@ class TheseService extends BaseService

        $fichier->setEstConforme($conforme);

        try {
            $this->entityManager->flush($fichier);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }
    }

    /**
@@ -296,7 +328,11 @@ class TheseService extends BaseService
            $this->entityManager->persist($rdvBu);
        }

        try {
            $this->entityManager->flush($rdvBu);
        } catch (OptimisticLockException $e) {
            throw new RuntimeException("Erreur rencontrée lors de l'enregistrement", null, $e);
        }

        // si tout est renseigné, on valide automatiquement
        if ($rdvBu->isInfosBuSaisies()) {