diff --git a/route.php b/route.php index 34273da..f741dd3 100644 --- a/route.php +++ b/route.php @@ -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 .= "

The Exception code was 0 and converted to 500

\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 .= "

The Exception code was 0 and converted to 500

\n"; + $getCode = $e->getCode (); } // If an error class/method is defined, use it in place of the default