From 79cf60764b5033edcf2962ccf3ee6d1706b41230 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 20 Feb 2016 14:23:59 -0500 Subject: Hook new Except MVC from the Root controller This patch encapsulates all app operations in a try block, and handles any exception by passing it into the new 'Except' MVC to be displayed --- app/controller/root.control.php | 43 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'app/controller') diff --git a/app/controller/root.control.php b/app/controller/root.control.php index 06abf27..2c60faf 100644 --- a/app/controller/root.control.php +++ b/app/controller/root.control.php @@ -2,6 +2,7 @@ require_once "class/controller.class.php"; require_once "controller/sysconf.control.php"; +require_once "controller/except.control.php"; require_once "controller/auth.control.php"; /* @@ -15,32 +16,40 @@ class Root extends Controller */ function handle($argv) { - /* TODO -- Catch app exceptions here and display a special view to communicate them to user */ /* TODO -- Authentication (login / logout / register) MVC */ $argv = $this->normalizeArgv($argv); - /* First, make sure the system configuration file has been included */ - if (!$this->scrottConfExists()) + try { - $ctrl = new Sysconf(); - $ctrl->handle($argv); - } + /* First, make sure the system configuration file has been included */ + if (!$this->scrottConfExists()) + { + $ctrl = new Sysconf(); + $ctrl->handle($argv); + } - /* TODO */ - /* TODO -- only auth if logged out */ - else if (!$this->getCurrentUser()) - { - $ctrl = new Auth(); - $ctrl->handle($argv); + /* TODO */ + /* TODO -- only auth if logged out */ + else if (!$this->getCurrentUser()) + { + $ctrl = new Auth(); + $ctrl->handle($argv); + } + + else + { + echo "logged in as:!"; + echo "
";
+                var_dump($this->getCurrentUser());
+                echo "
"; + } } - else + catch (Exception $e) { - echo "logged in as:!"; - echo "
";
-            var_dump($this->getCurrentUser());
-            echo "
"; + $ctrl = new Except(); + $ctrl->handle($e->getMessage()); } } -- cgit v1.2.3