{
if ($verify === false)
{
- $this->_error(new Exception(sprintf(_('Validation of "%1$s" failed'), $field)));
+ $this->_error(new FieldException(sprintf(_('Validation of "%1$s" failed'), $field)));
}
else
{
{
if (!isset($this->values["$name"]))
{
- $this->_error(new Exception(sprintf(_('The required field "%1$s" was not set'), $name), $name));
+ $this->_error(new FieldException(sprintf(_('The required field "%1$s" was not set'), $name), $name));
}
}
else if ($options[F_REQ] == REQ_SET)
{
if ($this->values["$field"] == 0)
{
- return new Exception(sprintf(_('The field "%1$s" cannot be zero'), $field), $field);
+ return new FieldException(sprintf(_('The field "%1$s" cannot be zero'), $field), $field);
}
return true;
{
if (empty($this->values["$field"]))
{
- return new Exception(sprintf(_('The field "%1$s" cannot be empty'), $field), $field);
+ return new FieldException(sprintf(_('The field "%1$s" cannot be empty'), $field), $field);
}
return true;
$res = BSApp::Registry()->getType('Db')->queryFirst("SELECT $field FROM {$this->prefix}{$this->table} WHERE $field = " . $this->_prepareFieldForSql($field) . (empty($this->condition) ? "" : " AND !({$this->condition})"));
if ($res)
{
- return new Exception(sprintf(_('The "%1$s" field must contain a unique value'), $field), $field);
+ return new FieldException(sprintf(_('The "%1$s" field must contain a unique value'), $field), $field);
}
return true;
}
}
+/**
+ * Field Exception
+ *
+ * This exception represents a problem with an API field
+ *
+ * @author rsesek
+ * @copyright Copyright (c)2002 - 2007, Blue Static
+ * @version $Id$
+ * @package ISSO
+ *
+ */
+class FieldException extends Exception
+{
+ /**
+ * The name of the erroring field
+ * @var string
+ */
+ private $field;
+
+ // ###################################################################
+ /**
+ * Constructor: create a new exception
+ */
+ public function __construct($error, $field)
+ {
+ $this->field = $field;
+ parent::__construct($error);
+ }
+
+ // ###################################################################
+ /**
+ * Returns the name of the field the exception is for
+ *
+ * @return string
+ */
+ public function getField()
+ {
+ return $this->field;
+ }
+}
+
?>
\ No newline at end of file