php - CodeIgniter not loading extended MY_Exceptions -


i'm trying override show_404 method ci_exceptions, my_exceptions never loaded.

my_exceptions located @ application/core/

it's code

<?php class my_exceptions extends ci_exceptions {     function show_404(){         header("http/1.1 404 not found");         $ci =& get_instance();         $ci->load->view('header.php');         $ci->load->view('err/custom404.php');         $ci->load->view('footer.php');     } } 

when call show_404() 2 fatal error

fatal error: class 'my_exceptions' not found in c:\workspace\ictp-tv-main\system\core\common.php on line 196

fatal error: class 'my_exceptions' not found in c:\workspace\ictp-tv-main\system\core\common.php on line 196

i have other extended classes work well, same prefix my_

edit after @tpojka suggestion code is

class my_exceptions extends ci_exceptions {      public function __construct()     {         parent::__construct();         $this->ci =& get_instance();     }      public function show_404($page = '', $log_error = true){          header("http/1.1 404 not found");          $this->ci->load->view('header.php');         $this->ci->load->view('err/custom404.php');         $this->ci->load->view('footer.php');      } } 

and 404 page blank.

edit

solution

we need echo error, not simple load view.

public function show_404($page = '', $log_error = true){     header("http/1.1 404 not found");     echo $this->ci->load->view('header.php',array('page_title'=>'page not found'),true);     echo $this->ci->load->view('err/custom404.php',null,true);     echo $this->ci->load->view('footer.php',null,true);     exit(4); } 

thanks @tpojka open mind.

try way

<? class my_exceptions extends ci_exceptions {     public function __construct()     {         parent::__construct();     }      public function show_404($page = '', $log_error = true)     {         if (is_cli())         {             $heading = 'not found';             $message = 'the controller/method pair requested not found.';         }         else         {             $heading = '404 page not found time';             $message = 'the page requested not found.';         }         // default log this, allow dev skip         if ($log_error)         {             log_message('error', $heading.': '.$page);         }         echo $this->show_error($heading, $message, 'custom404', 404);//custom404 in apppath.'views/errors/html/custom404.php'         exit(4); // exit_unknown_file     } } 

i edited code above. took research , ended this. copied show_404() method ci_exceptions class , saw changes done. can set message, header , call template well. can play way. suggest place $this->load->view('header') , $this->load->view('footer') in custom404.php file itself. in file custom404.php file echo $heading , $message.


Comments