Development

Changeset 8112

You must first sign up to be able to contribute.

Changeset 8112

Show
Ignore:
Timestamp:
03/27/08 13:47:34 (7 months ago)
Author:
fabien
Message:

added some exception when trying to load data from a non existing class (closes #3210 - based on a patch from trivoallan)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php

    r7892 r8112  
    9595      { 
    9696        // create a new entry in the database 
     97        if (!class_exists($class)) 
     98        { 
     99          throw new InvalidArgumentException(sprintf('Unknown class "%s".', $class)); 
     100        } 
     101 
    97102        $obj = new $class(); 
    98103 
    99104        if (!$obj instanceof BaseObject) 
    100105        { 
    101           throw new Exception(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $class, $class)); 
     106          throw new RuntimeException(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $class, $class)); 
    102107        } 
    103108 
    104109        if (!is_array($data)) 
    105110        { 
    106           throw new Exception(sprintf('You must give a name for each fixture data entry (class %s)', $class)); 
     111          throw new InvalidArgumentException(sprintf('You must give a name for each fixture data entry (class %s).', $class)); 
    107112        } 
    108113 
     
    136141              if (!isset($this->object_references[$relatedTable->getPhpName().'_'.$value])) 
    137142              { 
    138                 throw new sfException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedTable->getPhpName())); 
     143                throw new InvalidArgumentException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedTable->getPhpName())); 
    139144              } 
    140145              $value = $this->object_references[$relatedTable->getPhpName().'_'.$value]->getPrimaryKey(); 
     
    152157          else 
    153158          { 
    154             throw new sfException(sprintf('Column "%s" does not exist for class "%s"', $name, $class)); 
     159            throw new InvalidArgumentException(sprintf('Column "%s" does not exist for class "%s".', $name, $class)); 
    155160          } 
    156161        } 
     
    188193    if (!isset($relatedClass)) 
    189194    { 
    190       throw new sfException(sprintf('Unable to find the many-to-many relationship for object "%s"', get_class($obj))); 
     195      throw new InvalidArgumentException(sprintf('Unable to find the many-to-many relationship for object "%s".', get_class($obj))); 
    191196    } 
    192197 
     
    198203      if (!isset($this->object_references[$relatedClass.'_'.$value])) 
    199204      { 
    200         throw new sfException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedClass)); 
     205        throw new InvalidArgumentException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedClass)); 
    201206      } 
    202207 
     
    244249        { 
    245250          continue; 
     251        } 
     252 
     253        // Check that peer class exists before calling doDeleteAll() 
     254        if (!class_exists($class.'Peer')) 
     255        { 
     256          throw new InvalidArgumentException(sprintf('Unknown class "%sPeer".', $class)); 
    246257        } 
    247258