From 939837066421794d1255ea9a8c7b38b82a25e03d Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sun, 1 Jun 2014 07:53:46 +0000 Subject: [PATCH] Catch the non catched exception in routes and display them in Internal server error git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1374 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- route.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/route.php b/route.php index 12160b2..41ce1d2 100644 --- a/route.php +++ b/route.php @@ -530,7 +530,17 @@ class route { if ($this->debug) echo "==> FOUND EQUAL !\n"; - $function (); + try + { + $function (); + } + catch (Exception $e) + { + header ($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error"); + // TODO : Allow a specific page to be configured and displayed + echo "

Internal server error

"; + echo $e->getMessage(); + } exit; } @@ -556,7 +566,18 @@ class route else $params[] = null; } - call_user_func_array ($function, $params); + + try + { + call_user_func_array ($function, $params); + } + catch (Exception $e) + { + header ($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error"); + // TODO : Allow a specific page to be configured and displayed + echo "

Internal server error

"; + echo $e->getMessage(); + } exit; }