From a842392c30e9ef1d1d2bd9b4eb271c3fd23b853f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 3 Feb 2015 17:17:27 +0100 Subject: Use exceptions instead of show_error Signed-off-by: Florian Pritz --- application/core/MY_Controller.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'application/core') diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 0f71a7fdc..a58d03563 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -18,10 +18,12 @@ class MY_Controller extends CI_Controller { $this->var = new StdClass(); $csrf_protection = true; + $this->load->library('customautoloader'); + // check if DB is up to date if (!$this->input->is_cli_request()) { if (!$this->db->table_exists('migrations')){ - show_error("Database not initialized. Can't find migrations table. Please run the migration script. (php index.php tools update_database)"); + throw new \exceptions\PublicApiException("general/db/not-initialized", "Database not initialized. Can't find migrations table. Please run the migration script. (php index.php tools update_database)"); } else { $this->config->load("migration", true); $target_version = $this->config->item("migration_version", "migration"); @@ -31,7 +33,7 @@ class MY_Controller extends CI_Controller { $current_version = $row ? $row->version : 0; if ($current_version != $target_version) { - show_error("Database version is $current_version, we want $target_version. Please run the migration script. (php index.php tools update_database)"); + throw new \exceptions\PublicApiException("general/db/wrong-version", "Database version is $current_version, we want $target_version. Please run the migration script. (php index.php tools update_database)"); } } } @@ -41,7 +43,6 @@ class MY_Controller extends CI_Controller { mb_internal_encoding('UTF-8'); $this->load->helper(array('form', 'filebin')); - $this->load->library('customautoloader'); if ($this->uri->segment(1) == "api") { is_cli_client(true); -- cgit v1.2.3-24-g4f1b