How do I catch this type of error?
ContextErrorException: Catchable Fatal Error: Argument 1 passed to AA\SomeBundle\Entity\SomeEntity::setCity() must be an instance of AA\SomeBundle\Entity\City, null given, called in /srv/dev/some_path/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 360 and defined in /srv/dev/some_path/src/AA/SomeBundle/Entity/SomeEntity.php line 788
And I am trying to catch everything like that:
$form = $this->createForm(new SomeFormType(), $instanceOfSomeEntity);
try {
$form->handleRequest($request);
} catch (\Exception $e) {
$form->addError(new FormError('missing_information'));
}
city
field null. Usevalidation constraints
to make sure that user set some value – Bartek