Browse Source

Improve exception messages

Konstantin.Myakshin 9 years ago
parent
commit
75fd9638d9
2 changed files with 2 additions and 2 deletions
  1. 1 1
      Form/ChoiceList/ModelChoiceList.php
  2. 1 1
      Form/ChoiceList/ModelChoiceLoader.php

+ 1 - 1
Form/ChoiceList/ModelChoiceList.php

@@ -153,7 +153,7 @@ class ModelChoiceList extends SimpleChoiceList
                 try {
                 try {
                     $value = (string) $entity;
                     $value = (string) $entity;
                 } catch (\Exception $e) {
                 } catch (\Exception $e) {
-                    throw new RuntimeException(sprintf("Unable to convert the entity %s to String, entity must have a '__toString()' method defined", ClassUtils::getClass($entity)), 0, $e);
+                    throw new RuntimeException(sprintf('Unable to convert the entity "%s" to string, provide "property" option or implement "__toString()" method in your entity.', ClassUtils::getClass($entity)), 0, $e);
                 }
                 }
             }
             }
 
 

+ 1 - 1
Form/ChoiceList/ModelChoiceLoader.php

@@ -96,7 +96,7 @@ class ModelChoiceLoader implements ChoiceLoaderInterface
                     try {
                     try {
                         $valueObject = (string) $entity;
                         $valueObject = (string) $entity;
                     } catch (\Exception $e) {
                     } catch (\Exception $e) {
-                        throw new RuntimeException(sprintf("Unable to convert the entity %s to String, entity must have a '__toString()' method defined", ClassUtils::getClass($entity)), 0, $e);
+                        throw new RuntimeException(sprintf('Unable to convert the entity "%s" to string, provide "property" option or implement "__toString()" method in your entity.', ClassUtils::getClass($entity)), 0, $e);
                     }
                     }
                 }
                 }