route : if there is an error with the ratelimiter (directory not writeable...), averload the exception by the ratelimiter exception

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2699 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-04-19 13:04:54 +00:00
parent 5ad792d251
commit 18a641ca87

View File

@@ -507,22 +507,32 @@ class route
$ipClient = $_SERVER["REMOTE_ADDR"];
elseif (defined ("PHPUNIT"))
$ipClient = "CLI";
if ($this->ratelimiter !== null && $ipClient !== null &&
$this->ratelimiter->set ("error-$ipClient") === false)
try
{
$getCode = 406;
$message = dgettext("domframework", "Too much error requests");
}
else
{
if ($e->getCode () === "" || $e->getCode () === 0)
$getCode = 500;
if ($this->ratelimiter !== null && $ipClient !== null &&
$this->ratelimiter->set ("error-$ipClient") === false)
{
$getCode = 406;
$message = dgettext("domframework", "Too much error requests");
}
else
$getCode = $e->getCode ();
{
if ($e->getCode () === "" || $e->getCode () === 0)
$getCode = 500;
else
$getCode = $e->getCode ();
$message = $e->getMessage ();
if ($e->getCode () === 0)
$message .= "<p>The Exception code was 0 and converted to 500</p>\n";
}
}
catch (Exception $e)
{
// If there is an error with the ratelimiter (file not writeable...),
// overload the Exception
$message = $e->getMessage ();
if ($e->getCode () === 0)
$message .= "<p>The Exception code was 0 and converted to 500</p>\n";
$getCode = $e->getCode ();
}
// If an error class/method is defined, use it in place of the default