1
0
mirror of synced 2025-02-06 15:29:26 +03:00

Better error handling on missing assigned id

This commit is contained in:
Asmir Mustafic 2011-09-29 09:31:06 +02:00
parent 80284a273d
commit d24f288149
2 changed files with 16 additions and 9 deletions

View File

@ -60,7 +60,7 @@ class AssignedGenerator extends AbstractIdGenerator
$identifier[$idField] = $value;
}
} else {
throw ORMException::entityMissingAssignedId($entity);
throw ORMException::entityMissingAssignedIdForField($entity, $idField);
}
}
} else {

View File

@ -54,7 +54,14 @@ class ORMException extends Exception
"you need to adjust the metadata mapping accordingly."
);
}
public static function entityMissingAssignedIdForField($entity, $field)
{
return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " .
"The identifier generation strategy for this entity requires the ID field to be populated before ".
"EntityManager#persist() is called. If you want automatically generated identifiers instead " .
"you need to adjust the metadata mapping accordingly."
);
}
public static function unrecognizedField($field)
{
return new self("Unrecognized field: $field");