Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 014285d

Browse files
committed
[DoctrineBridge] Add more specific exception
1 parent 7125a5c commit 014285d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\Validator\ConstraintValidator;
1818
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1919
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
20+
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
21+
use Doctrine\Persistence\Mapping\MappingException as PersistenceMappingException;
2022

2123
/**
2224
* Unique Entity Validator checks if one or a set of fields contain unique values.
@@ -85,7 +87,7 @@ public function validate($object, Constraint $constraint)
8587
try {
8688
$repository = $em->getRepository($entityClass);
8789
$isEntity = true;
88-
} catch (\Exception $e) {
90+
} catch (ORMMappingException | PersistenceMappingException $e) {
8991
$isEntity = false;
9092
}
9193

0 commit comments

Comments
 (0)