Welcome Guest, Not a member yet? Register   Sign In
MY_EXECPTION different in development and poduction
#1

Hi every body. I would like to have 2 different versions of MY_Exceptions.php :
In development mode :


Code:
class MY_Exceptions extends CI_Exceptions {

    function __construct() {
        parent::__construct();
    }
}

In production mode :

Code:
class MY_Exceptions extends CI_Exceptions {

    function __construct() {
        parent::__construct();
    }


    public function show_error($heading, $message, $template = 'error_general', $status_code = 500) {
         // I do custom actions here   
    }
}



Any idea or help on how I could do this?
Reply
#2

Check the ENVIRONMENT constant and call the parent method or do your custom action:

PHP Code:
if (ENVIRONMENT == ‘production’) {
    // do custom action
} else {
    // call parent method from original class
    parent::show_error($heading$message$template$status_code);

CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB