CodeIgniter Forums
MY_EXECPTION different in development and poduction - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: MY_EXECPTION different in development and poduction (/showthread.php?tid=80262)



MY_EXECPTION different in development and poduction - imabot2 - 10-08-2021

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?


RE: MY_EXECPTION different in development and poduction - includebeer - 10-09-2021

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);