route: catch the exception generated by route itself, and display the error page

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3732 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2017-05-29 12:30:34 +00:00
parent 484a892836
commit ee285f0e41

View File

@@ -296,7 +296,7 @@ class route
} }
if (!isset ($_SERVER["REQUEST_METHOD"])) if (!isset ($_SERVER["REQUEST_METHOD"]))
throw new Exception ("No REQUEST_METHOD", 415); $this->error (new \Exception ("No REQUEST_METHOD", 415));
if ($_SERVER["REQUEST_METHOD"] === "GET" || if ($_SERVER["REQUEST_METHOD"] === "GET" ||
$_SERVER["REQUEST_METHOD"] === "POST" || $_SERVER["REQUEST_METHOD"] === "POST" ||
$_SERVER["REQUEST_METHOD"] === "PUT" || $_SERVER["REQUEST_METHOD"] === "PUT" ||
@@ -306,7 +306,7 @@ class route
return $_SERVER["REQUEST_METHOD"]; return $_SERVER["REQUEST_METHOD"];
} }
throw new Exception ("Invalid REQUEST_METHOD", 406); $this->error (new \Exception ("Invalid REQUEST_METHOD", 406));
} }
/** Return the mached route search /** Return the mached route search
@@ -492,8 +492,8 @@ class route
if ($rcRegex === false) if ($rcRegex === false)
{ {
if (count (error_get_last())) if (count (error_get_last()))
throw new \Exception ("Invalid regex provided: $regex : ". $this->error (new \Exception ("Invalid regex provided: $regex : ".
error_get_last()["message"], 500); error_get_last()["message"], 500));
} }
if ($rcRegex !== FALSE && $rcRegex !== 0) if ($rcRegex !== FALSE && $rcRegex !== 0)
{ {