Przeglądaj źródła

[Modify]StringCastExceptin to RuntimeException and add the exception instance

Varayut Lerdkanlayanawat 11 lat temu
rodzic
commit
ac96b10c71
1 zmienionych plików z 2 dodań i 1 usunięć
  1. 2 1
      Form/ChoiceList/ModelChoiceList.php

+ 2 - 1
Form/ChoiceList/ModelChoiceList.php

@@ -15,6 +15,7 @@ use Doctrine\Common\Util\ClassUtils;
 use Symfony\Component\PropertyAccess\PropertyAccess;
 use Symfony\Component\PropertyAccess\PropertyPath;
 use Symfony\Component\Form\Exception\InvalidArgumentException;
+use Symfony\Component\Form\Exception\RuntimeException;
 use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
 use Sonata\AdminBundle\Model\ModelManagerInterface;
 
@@ -140,7 +141,7 @@ class ModelChoiceList extends SimpleChoiceList
                 try {
                     $value = (string) $entity;
                 } catch (\Exception $e) {
-                    throw new StringCastException(sprintf("Unable to convert the entity %s to String, entity must have a '__toString()' method defined", ClassUtils::getClass($entity)));
+                    throw new RuntimeException(sprintf("Unable to convert the entity %s to String, entity must have a '__toString()' method defined", ClassUtils::getClass($entity)), 0, $e);
                 }
             }