Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Added extended debugging information to formatter failures
Browse files Browse the repository at this point in the history
  • Loading branch information
lexicalbits authored and fzaninotto committed Apr 29, 2016
1 parent 598e51e commit 050954b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Faker/ORM/Doctrine/EntityPopulator.php
Expand Up @@ -186,7 +186,16 @@ private function fillColumns($obj, $insertedEntities)
{
foreach ($this->columnFormatters as $field => $format) {
if (null !== $format) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
//Add some extended debugging information to any errors thrown by the formatter
try {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
} catch(\InvalidArgumentException $ex) {
throw new \InvalidArgumentException(sprintf("Failed to generate a value for %s::%s: %s",
get_class($obj),
$field,
$ex->getMessage()
));
}
$this->class->reflFields[$field]->setValue($obj, $value);
}
}
Expand Down

0 comments on commit 050954b

Please sign in to comment.