Преглед на файлове

[Modify]StringCastExceptin to RuntimeException and add the exception instance

Varayut Lerdkanlayanawat преди 11 години
родител
ревизия
ac96b10c71
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  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);
                 }
             }