Finaly bekam ich die Lösung für mein Problem und ich möchte mit Ihnen die Lösung teilen
try {
$em = $this->get('doctrine.orm.entity_manager');
$em->persist($transaction);
$em->flush();
} catch(\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(409, "Transaction already exist");
} catch(\Doctrine\DBAL\Exception\ConstraintViolationException $e) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(409, "Bad request on Transaction");
} catch(\Doctrine\DBAL\Exception\TableNotFoundException $e) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(409, "Transaction Table not found");
}
Dieser Link alle Exception in Lehre
enthält
https://github.com/doctrine/dbal/tree/master/lib/Doctrine/DBAL/Exception
... und was ist los? Was * passiert * nicht? Was willst du passieren? – iainn
Ich möchte die Ausnahme abfangen, die passieren wird: EntityAlreadyExist, UniqueConstraint, der Code, den ich auf meiner Frage hinter mir habe, funktioniert nicht für mich –