2

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?

0

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

6 Comments

sorry, that was a typo - i do have it named MY_Exceptions.php
You still don't need to load it, it's always loaded (and very early). Try just running CI without manually loading the class, you should be fine.
@Dhana: Are you sure you have followed the instructions correctly? The docs you are looking at are for non-core libraries.
Boy, today is definitely a typo day - I just realized I gave the wrong link too - I did follow the instructions on extending the core class
You're not trying to call the class manually are you? I've got to go back to work, GL.
|
0

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

1 Comment

sorry, that was a typo - i do have it named MY_Exceptions.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.