From 84ec6dc9f5925af77513fb6234f5f8b77ccfa2e5 Mon Sep 17 00:00:00 2001 From: "Johannes M. Schmitt" Date: Wed, 4 Apr 2012 21:47:23 -0500 Subject: [PATCH] improved exception message --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 6 ++++-- lib/Doctrine/ORM/Mapping/MappingException.php | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index b36b7121e..8f136b2eb 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1212,7 +1212,9 @@ class ClassMetadataInfo implements ClassMetadata if (count($cascades) !== count(array_intersect($cascades, array('remove', 'persist', 'refresh', 'merge', 'detach')))) { throw MappingException::invalidCascadeOption( - array_diff($cascades, array_intersect($cascades, array('remove', 'persist', 'refresh', 'merge', 'detach'))) + array_diff($cascades, array_intersect($cascades, array('remove', 'persist', 'refresh', 'merge', 'detach'))), + $this->name, + $mapping['fieldName'] ); } @@ -1596,7 +1598,7 @@ class ClassMetadataInfo implements ClassMetadata { return $this->generatorType == self::GENERATOR_TYPE_NONE; } - + /** * Checks whether the class use a UUID for id generation * diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 3e8022280..864c26871 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -355,12 +355,14 @@ class MappingException extends \Doctrine\ORM\ORMException return new self("The target-entity " . $targetEntity . " cannot be found in '" . $sourceEntity."#".$associationName."'."); } - public static function invalidCascadeOption(array $cascades) + public static function invalidCascadeOption(array $cascades, $className, $propertyName) { $cascades = implode(", ", array_map(function ($e) { return "'" . $e . "'"; }, $cascades)); - return new self( - "Invalid cascade option(s) specified: " . $cascades . ". " . - "Only 'remove', 'persist', 'refresh', 'merge' and 'detach' are allowed." - ); + return new self(sprintf( + 'You have specified invalid cascade options for %s::$%s: %s; available options: "remove", "persist", "refresh", "merge", and "detach"', + $className, + $propertyName, + $cascades + )); } }