DLS
DLS

Reputation: 5491

Codeigniter extending exception class

I am trying to load a custom exception class that I created according to the instructions here:

http://codeigniter.com/user_guide/general/core_classes.html

MY_Exceptions.php is stored at application/core/

Somehow, when I try loading it, I keep getting this error:

Fatal error: Class 'MY_Exceptions' not found in C:\xampp\htdocs\xampp\facebook\application\models\campaign_model.php on line 29

Based on the instructions, it doesn't say I have to autoload the class or anything. What am I doing wrong?

Upvotes: 2

Views: 5474

Answers (2)

No Results Found
No Results Found

Reputation: 102745

MY_Exception.php is stored at application/core/

Name the class and file MY_Exceptions with an s

You do not need to autoload or manually load anything in the core directory, nor should you. They are required classes for CI to run that are automatically loaded.

For creating core classes, use this documentation instead: http://codeigniter.com/user_guide/general/core_classes.html

Keep in mind that when calling the class you will use the original class name. Let's say you have created MY_Input. Example:

$this->input->post();  // Do this
$this->my_input->post(); // Don't do this

To understand the why and how, see system/core/Common.php function load_class.

Looking at the docs now, I agree that this should probably be highlighted.

Upvotes: 2

Yeroon
Yeroon

Reputation: 3243

It's trying to find MY_ExceptionS.php, not MY_Exception.php.

Upvotes: 0

Related Questions