Welcome Guest, Not a member yet? Register   Sign In
Extending CI_Exceptions
#1

(This post was last modified: 11-24-2016, 11:11 AM by Auk.)

Hello,
I'm trying to extend CI_Exceptions but I can't access the load method in my sub class.
I tried :
PHP Code:
class MY_Exceptions extends CI_Exceptions {

    protected $CI;

 
   public function __construct()
 
   {
 
       parent::__construct();
 
       $this->CI =& get_instance();
 
       $this->CI->load->library('SOMELIBRARY');
 
   
Thanks in advance,
Reply
#2

This might help ... http://www.codeigniter.com/user_guide/ge...t-instance
Reply
#3

As mentionend previously, I tried this method.
The error output : Fatal error: Call to a member function library() on a non-object in
Reply
#4

Sorry - I was looking at your original github issue, where you had $this->load...

If still getting an undefined property, that suggests to me that the CI instance is not fully constructed when the Exceptions class is loaded, and that you might have to reference CI etc in one of the work methods, eg log_exception(...)
Reply
#5

(This post was last modified: 11-24-2016, 02:24 PM by Auk.)

I tried to use $this->_CI->load->library('twig'); in the show_error method without success.
Error output : Message: Trying to get property of non-object.
BTW I extended the Loader class and could not load a library in the constructor. However, it worked in the methods.
I guess CI_Loader is instantiated before CI_Exceptions.
What could be a good solution to my problem ?
Reply
#6

Any news ?
Reply
#7

CI is not yet loaded so you will get an Error.

See CodeIgniter.php to see how it is loading things.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB