dblayeroo : return 406 instead of 500 if the provided values checked are invalid. It is not a server bug, it is a client bug

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4633 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-10-25 09:01:53 +00:00
parent 95f7b55681
commit 0bd2861c98

View File

@@ -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
*/