From 7f5844d1dbcbb833d0cbded32149ed65f42f5a29 Mon Sep 17 00:00:00 2001 From: doctrine Date: Mon, 7 Aug 2006 20:58:09 +0000 Subject: [PATCH] Doctrine_Record_Exception: better handling of error messages --- Doctrine/Hydrate.php | 2 -- Doctrine/Record.php | 8 ++++---- Doctrine/Record/Exception.php | 11 ++--------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Doctrine/Hydrate.php b/Doctrine/Hydrate.php index ce38a00d3..7137edab0 100644 --- a/Doctrine/Hydrate.php +++ b/Doctrine/Hydrate.php @@ -272,8 +272,6 @@ class Doctrine_Hydrate extends Doctrine_Access { if($return == Doctrine::RETURN_VHOLDER) { return $this->hydrateHolders($array); } - - $colls = array(); foreach($array as $data) { /** diff --git a/Doctrine/Record.php b/Doctrine/Record.php index 4e6ed0b82..8886937d4 100644 --- a/Doctrine/Record.php +++ b/Doctrine/Record.php @@ -491,7 +491,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $this->prepareIdentifiers(); if($this->id != $old) - throw new Doctrine_Record_Exception(); + throw new Doctrine_Record_Exception("The refreshed primary key doesn't match the one in the record memory.", Doctrine::ERR_REFRESH); $this->state = Doctrine_Record::STATE_CLEAN; $this->modified = array(); @@ -679,7 +679,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite case Doctrine_Relation::MANY_AGGREGATE: // one-to-many relation found if( ! ($value instanceof Doctrine_Collection)) - throw new Doctrine_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); + throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); $value->setReference($this,$fk); break; @@ -687,7 +687,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite case Doctrine_Relation::ONE_AGGREGATE: // one-to-one relation found if( ! ($value instanceof Doctrine_Record)) - throw new Doctrine_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record when setting one-to-one references."); + throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record when setting one-to-one references."); if($fk->getLocal() == $this->table->getIdentifier()) { $this->references[$name]->set($fk->getForeign(),$this); @@ -700,7 +700,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } elseif($fk instanceof Doctrine_Association) { // join table relation found if( ! ($value instanceof Doctrine_Collection)) - throw new Doctrine_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); + throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); } $this->references[$name] = $value; diff --git a/Doctrine/Record/Exception.php b/Doctrine/Record/Exception.php index 37eed6fe0..3e3c9ae02 100644 --- a/Doctrine/Record/Exception.php +++ b/Doctrine/Record/Exception.php @@ -1,12 +1,5 @@