diff --git a/dblayeroo.php b/dblayeroo.php index a3fc6a4..8786935 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -2609,7 +2609,7 @@ class dblayeroo // {{{ { if (! is_array ($values)) - $this->DBException ("Invalid values to normalize : not an array"); + $this->DBException ("Invalid values to normalize : not an array", 406); $values = array_map ("trim", $values); return $values; } @@ -2838,7 +2838,7 @@ class dblayeroo } if (count ($errors) == 0 && count ($objTmp->execute ())) $this->DBException (dgettext ("domframework", - "An entry with these values already exists")); + "An entry with these values already exists"), 406); unset ($objTmp); } @@ -2910,10 +2910,10 @@ class dblayeroo $values = $this->setValues; $errors = $this->checkRealTypes ($values, $update); if (count ($errors)) - $this->DBException (reset ($errors)); + $this->DBException (reset ($errors), 406); $errors = $this->verify ($values, $update); if (count ($errors)) - $this->DBException (reset ($errors)); + $this->DBException (reset ($errors), 406); $this->debugLog ("End of checkValues (",$update,") : Nothing in error"); } /* }}} */ @@ -3142,12 +3142,13 @@ class dblayeroo /** Error management * @param string $message The message to throw in the exception + * @param integer|null $code The error code to return to the user */ - public function DBException ($message) + public function DBException ($message, $code = 500) /* {{{ */ { $message = $this->DBExceptionMsg ($message); - throw new \Exception ($message, 500); + throw new \Exception ($message, $code); } /* }}} */ @@ -3175,8 +3176,8 @@ class dblayeroo } return $message; } - /* }}} */ + /** Debug function * @param mixed ...$message The message to display in debug */