Development

Changeset 6196

You must first sign up to be able to contribute.

Changeset 6196

Show
Ignore:
Timestamp:
11/28/07 08:49:12 (2 years ago)
Author:
fabien
Message:

replaced sfException exceptions to SPL exceptions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/form/sfForm.class.php

    r6158 r6196  
    500500      if (!$widget = $this->widgetSchema[$name]) 
    501501      { 
    502         throw new sfException(sprintf('Widget "%s" does not exist.', $name)); 
     502        throw new InvalidArgumentException(sprintf('Widget "%s" does not exist.', $name)); 
    503503      } 
    504504 
     
    517517   * @param string (ignored) 
    518518   * 
    519    * @throws <b>sfException</b> 
     519   * @throws <b>LogicException</b> 
    520520   */ 
    521521  public function offsetSet($offset, $value) 
    522522  { 
    523     throw new sfException('Cannot update form fields.'); 
     523    throw new LogicException('Cannot update form fields.'); 
    524524  } 
    525525 
  • trunk/lib/form/sfFormField.class.php

    r6114 r6196  
    8282    if ($this->widget instanceof sfWidgetFormSchema) 
    8383    { 
    84       throw new sfException('Unable to format a row on a sfWidgetFormSchema.'); 
     84      throw new LogicException('Unable to format a row on a sfWidgetFormSchema.'); 
    8585    } 
    8686 
     
    103103    if ($this->widget instanceof sfWidgetFormSchema) 
    104104    { 
    105       throw new sfException('Unable to format an error list on a sfWidgetFormSchema.'); 
     105      throw new LogicException('Unable to format an error list on a sfWidgetFormSchema.'); 
    106106    } 
    107107 
     
    118118    if ($this->widget instanceof sfWidgetFormSchema) 
    119119    { 
    120       throw new sfException('Unable to render a label on a sfWidgetFormSchema.'); 
     120      throw new LogicException('Unable to render a label on a sfWidgetFormSchema.'); 
    121121    } 
    122122 
     
    133133    if ($this->widget instanceof sfWidgetFormSchema) 
    134134    { 
    135       throw new sfException('Unable to render a label name on a sfWidgetFormSchema.'); 
     135      throw new LogicException('Unable to render a label name on a sfWidgetFormSchema.'); 
    136136    } 
    137137 
     
    224224      if (!$this->widget instanceof sfWidgetFormSchema) 
    225225      { 
    226         throw new sfException(sprintf('Cannot get a form field on a non widget schema (%s given).', get_class($this->widget))); 
     226        throw new LogicException(sprintf('Cannot get a form field on a non widget schema (%s given).', get_class($this->widget))); 
    227227      } 
    228228 
    229229      if (is_null($widget = $this->widget[$name])) 
    230230      { 
    231         throw new sfException(sprintf('Widget "%s" does not exist.', $name)); 
     231        throw new InvalidArgumentException(sprintf('Widget "%s" does not exist.', $name)); 
    232232      } 
    233233 
     
    244244   * @param string (ignored) 
    245245   * 
    246    * @throws <b>sfException</b> 
     246   * @throws <b>LogicException</b> 
    247247   */ 
    248248  public function offsetSet($offset, $value) 
    249249  { 
    250     throw new sfException('Cannot update form fields (read-only).'); 
     250    throw new LogicException('Cannot update form fields (read-only).'); 
    251251  } 
    252252 
     
    256256   * @param string (ignored) 
    257257   * 
    258    * @throws sfException 
     258   * @throws LogicException 
    259259   */ 
    260260  public function offsetUnset($offset) 
    261261  { 
    262     throw new sfException('Cannot remove form fields (read-only).'); 
     262    throw new LogicException('Cannot remove form fields (read-only).'); 
    263263  } 
    264264} 
  • trunk/lib/validator/sfValidator.class.php

    r6002 r6196  
    6161    if ($diff = array_diff(array_keys($options), array_merge(array_keys($this->options), $this->requiredOptions))) 
    6262    { 
    63       throw new sfException(sprintf('%s does not support the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
     63      throw new InvalidArgumentException(sprintf('%s does not support the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
    6464    } 
    6565 
     
    6767    if ($diff = array_diff(array_keys($messages), array_keys($this->messages))) 
    6868    { 
    69       throw new sfException(sprintf('%s does not support the following error codes: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
     69      throw new InvalidArgumentException(sprintf('%s does not support the following error codes: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
    7070    } 
    7171 
     
    7373    if ($diff = array_diff($this->requiredOptions, array_merge(array_keys($this->options), array_keys($options)))) 
    7474    { 
    75       throw new sfException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
     75      throw new RuntimeException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
    7676    } 
    7777 
     
    132132    if (!in_array($name, array_keys($this->messages))) 
    133133    { 
    134       throw new sfException(sprintf('%s does not support the following error code: \'%s\'.', get_class($this), $name)); 
     134      throw new InvalidArgumentException(sprintf('%s does not support the following error code: \'%s\'.', get_class($this), $name)); 
    135135    } 
    136136 
     
    191191    if (!in_array($name, array_merge(array_keys($this->options), $this->requiredOptions))) 
    192192    { 
    193       throw new sfException(sprintf('%s does not support the following option: \'%s\'.', get_class($this), $name)); 
     193      throw new InvalidArgumentException(sprintf('%s does not support the following option: \'%s\'.', get_class($this), $name)); 
    194194    } 
    195195 
  • trunk/lib/validator/sfValidatorAll.class.php

    r5816 r6196  
    5252    else if (!is_null($validators)) 
    5353    { 
    54       throw new sfException('sfValidatorAll constructor takes a sfValidator object, or a sfValidator array.'); 
     54      throw new InvalidArgumentException('sfValidatorAll constructor takes a sfValidator object, or a sfValidator array.'); 
    5555    } 
    5656 
  • trunk/lib/validator/sfValidatorAny.class.php

    r5816 r6196  
    5252    else if (!is_null($validators)) 
    5353    { 
    54       throw new sfException('sfValidatorAny constructor takes a sfValidator object, or a sfValidator array.'); 
     54      throw new InvalidArgumentException('sfValidatorAny constructor takes a sfValidator object, or a sfValidator array.'); 
    5555    } 
    5656 
  • trunk/lib/validator/sfValidatorDecorator.class.php

    r5816 r6196  
    3535    if (!$this->validator instanceof sfValidator) 
    3636    { 
    37       throw new sfException('The getValidator() method must return a sfValidator instance.'); 
     37      throw new RuntimeException('The getValidator() method must return a sfValidator instance.'); 
    3838    } 
    3939 
  • trunk/lib/validator/sfValidatorErrorSchema.class.php

    r5581 r6196  
    228228   * @param string (ignored) 
    229229   * 
    230    * @throws <b>sfException</b> 
     230   * @throws <b>LogicException</b> 
    231231   */ 
    232232  public function offsetSet($offset, $value) 
    233233  { 
    234     throw new sfException('Unable update an error.'); 
     234    throw new LogicException('Unable update an error.'); 
    235235  } 
    236236 
     
    239239   * 
    240240   * @param string (ignored) 
    241    * 
    242    * @throws sfException 
    243241   */ 
    244242  public function offsetUnset($offset) 
  • trunk/lib/validator/sfValidatorFromDescription.class.php

    r5753 r6196  
    8989        if (!preg_match('/\s*([a-z0-9_\-]+)/', substr($string, $i), $match)) 
    9090        { 
    91           throw new sfException('Parsing problem.'); 
     91          throw new DomainException('Parsing problem.'); 
    9292        } 
    9393 
     
    138138      else 
    139139      { 
    140         throw new sfException(sprintf('Unable to parse string (%s).', $string)); 
     140        throw new DomainException(sprintf('Unable to parse string (%s).', $string)); 
    141141      } 
    142142    } 
     
    238238      if ($token instanceof sfValidatorFDTokenLeftBracket || $token instanceof sfValidatorFDTokenRightBracket) 
    239239      { 
    240         throw new sfException(sprintf('Uneven parenthesis in string (%s).', $this->string)); 
     240        throw new DomainException(sprintf('Uneven parenthesis in string (%s).', $this->string)); 
    241241      } 
    242242 
  • trunk/lib/validator/sfValidatorSchema.class.php

    r5949 r6196  
    4949    else if (!is_null($fields)) 
    5050    { 
    51       throw new sfException('sfValidatorSchema constructor takes an array of sfValidator objects.'); 
     51      throw new InvalidArgumentException('sfValidatorSchema constructor takes an array of sfValidator objects.'); 
    5252    } 
    5353 
     
    100100    if (!is_array($values)) 
    101101    { 
    102       throw new sfException('You must pass an array parameter to the clean() method'); 
     102      throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); 
    103103    } 
    104104 
     
    227227    if (!$validator instanceof sfValidator) 
    228228    { 
    229       throw new sfException('A field must be an instance of sfValidator.'); 
     229      throw new InvalidArgumentException('A field must be an instance of sfValidator.'); 
    230230    } 
    231231 
     
    258258  public function asString($indent = 0) 
    259259  { 
    260     throw new sfException('Unable to convert a sfValidatorSchema to string.'); 
     260    throw new Exception('Unable to convert a sfValidatorSchema to string.'); 
    261261  } 
    262262} 
  • trunk/lib/validator/sfValidatorSchemaCompare.class.php

    r5882 r6196  
    6767    if (!is_array($values)) 
    6868    { 
    69       throw new sfException('You must pass an array parameter to the clean() method'); 
     69      throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); 
    7070    } 
    7171 
  • trunk/lib/validator/sfValidatorSchemaFilter.class.php

    r5882 r6196  
    4949    if (!is_array($values)) 
    5050    { 
    51       throw new sfException('You must pass an array parameter to the clean() method'); 
     51      throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); 
    5252    } 
    5353 
  • trunk/lib/validator/sfValidatorSchemaForEach.class.php

    r5753 r6196  
    4747  public function asString($indent = 0) 
    4848  { 
    49     throw new sfException('Unable to convert a sfValidatorSchemaForEach to string.'); 
     49    throw new Exception('Unable to convert a sfValidatorSchemaForEach to string.'); 
    5050  } 
    5151} 
  • trunk/lib/widget/sfWidget.class.php

    r6153 r6196  
    4141    if ($diff = array_diff(array_keys($options), array_merge(array_keys($this->options), $this->requiredOptions))) 
    4242    { 
    43       throw new sfException(sprintf('%s does not support the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
     43      throw new InvalidArgumentException(sprintf('%s does not support the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
    4444    } 
    4545 
     
    4747    if ($diff = array_diff($this->requiredOptions, array_merge(array_keys($this->options), array_keys($options)))) 
    4848    { 
    49       throw new sfException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
     49      throw new RuntimeException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 
    5050    } 
    5151 
     
    128128    if (!in_array($name, array_merge(array_keys($this->options), $this->requiredOptions))) 
    129129    { 
    130       throw new sfException(sprintf('%s does not support the following option: \'%s\'.', get_class($this), $name)); 
     130      throw new InvalidArgumentException(sprintf('%s does not support the following option: \'%s\'.', get_class($this), $name)); 
    131131    } 
    132132 
  • trunk/lib/widget/sfWidgetFormDateTime.class.php

    r5950 r6196  
    7575    if (!is_array($options)) 
    7676    { 
    77       throw new sfException(sprintf('You must pass an array for the %s option.', $type)); 
     77      throw new InvalidArgumentException(sprintf('You must pass an array for the %s option.', $type)); 
    7878    } 
    7979 
  • trunk/lib/widget/sfWidgetFormSchema.class.php

    r5995 r6196  
    6767    else if (!is_null($fields)) 
    6868    { 
    69       throw new sfException('sfWidgetFormSchema constructor takes an array of sfWidget objects.'); 
     69      throw new InvalidArgumentException('sfWidgetFormSchema constructor takes an array of sfWidget objects.'); 
    7070    } 
    7171 
     
    124124   * @return sfWidgetFormSchemaFormatter sfWidgetFormSchemaFormatter instance 
    125125   * 
    126    * @throws sfException 
     126   * @throws InvalidArgumentException 
    127127   */ 
    128128  public function getFormFormatter() 
     
    141141    } 
    142142 
    143     throw new sfException(sprintf('The form formatter "%s" does not exist.', $name)); 
     143    throw new InvalidArgumentException(sprintf('The form formatter "%s" does not exist.', $name)); 
    144144  } 
    145145 
     
    280280    if (is_null($widget = $this[$name])) 
    281281    { 
    282       throw new sfException(sprintf('The field named "%s" does not exist.', $name)); 
     282      throw new InvalidArgumentException(sprintf('The field named "%s" does not exist.', $name)); 
    283283    } 
    284284 
     
    309309    if (!is_array($values) && !$values instanceof ArrayAccess) 
    310310    { 
    311       throw new sfException('You must pass an array of values to render a widget schema'); 
     311      throw new InvalidArgumentException('You must pass an array of values to render a widget schema'); 
    312312    } 
    313313 
     
    460460    if (!$widget instanceof sfWidget) 
    461461    { 
    462       throw new sfException('A field must be an instance of sfWidget.'); 
     462      throw new InvalidArgumentException('A field must be an instance of sfWidget.'); 
    463463    } 
    464464 
     
    519519    if (array_diff($positions, array_keys($this->fields)) || array_diff(array_keys($this->fields), $positions)) 
    520520    { 
    521       throw new sfException('Positions must contains all field names.'); 
     521      throw new InvalidArgumentException('Positions must contains all field names.'); 
    522522    } 
    523523 
     
    543543    if (false === $fieldPosition = array_search($field, $this->positions)) 
    544544    { 
    545       throw new sfException(sprintf('Field "%s" does not exist.', $field)); 
     545      throw new InvalidArgumentException(sprintf('Field "%s" does not exist.', $field)); 
    546546    } 
    547547    unset($this->positions[$fieldPosition]); 
     
    552552      if (false === $pivotPosition = array_search($pivot, $this->positions)) 
    553553      { 
    554         throw new sfException(sprintf('Field "%s" does not exist.', $pivot)); 
     554        throw new InvalidArgumentException(sprintf('Field "%s" does not exist.', $pivot)); 
    555555      } 
    556556    } 
     
    567567        if (is_null($pivot)) 
    568568        { 
    569           throw new sfException(sprintf('Unable to move field "%s" without a relative field.', $field)); 
     569          throw new LogicException(sprintf('Unable to move field "%s" without a relative field.', $field)); 
    570570        } 
    571571        $this->positions = array_merge( 
     
    578578        if (is_null($pivot)) 
    579579        { 
    580           throw new sfException(sprintf('Unable to move field "%s" without a relative field.', $field)); 
     580          throw new LogicException(sprintf('Unable to move field "%s" without a relative field.', $field)); 
    581581        } 
    582582        $this->positions = array_merge( 
     
    587587        break; 
    588588      default: 
    589         throw new sfException(sprintf('Unknown move operation for field "%s".', $field)); 
     589        throw new LogicException(sprintf('Unknown move operation for field "%s".', $field)); 
    590590    } 
    591591  } 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.