Welcome Guest, Not a member yet? Register   Sign In
Class 'CI_Exceptions' not found
#1

[eluser]DanielH[/eluser]
Whenever I make any kind of syntax error in my code, I get a 500 error from my server, and php_error.log contains a line that looks like this:

[22-Nov-2008 18:08:12] PHP Fatal error: Class 'CI_Exceptions' not found in /code/trunk/webapp/system/codeigniter/Common.php on line 136

For example, I can reproduce this by taking any .php that was valid and removing a $ from the front of a variable.

This makes debugging extremely difficult, since CI cannot echo anything to the screen, and its debug log doesn't have much that's useful, even after I adjust error_reporting and log_threshold.

I am using CI 1.7, and I get this situation on XAMPP on Windows, MAMP on Mac, and from a standard Apache 2.2 install on OpenSolaris. My codebase is currently extremely simple -- I only have 2 or 3 controllers, no DB layer at all, and a handful of views.

I believe that what is happening is that CI wants to throw/report an error, but cannot because either something is wrong in my environment, or something is incorrect in the CI code itself (e.g., I have an extra file somewhere; I recently upgraded from CI 1.6 by downloading the 1.7 zip and copying over the top of 1.6). I have done a number of google searches, and I find other instances where people have this error, but there doesn't seem to be any unifying theme or smoking gun as to how their enivornment is misconfigured.

Has anyone seen this issue before?
#2

[eluser]DanielH[/eluser]
I just wanted to clarify the intent of this thread. I think it's a bug that CI fails with such an unhelpful message (class 'CI_Exceptions' not found) when a PHP file it's trying to execute has a syntax error. Shouldn't CI report an error instead?
#3

[eluser]Pascal Kriete[/eluser]
Just to rule out file corruption ... try replacing /system/libraries/Exceptions.php with the newest version.
#4

[eluser]DanielH[/eluser]
I figured out the problem. I had added a new file, Exceptions.php, in system/application/libraries. This was interfering with CI's built-in error-handling logic. We should probably document that adding a file with that name in system/application/libraries will cause problems, or make CI's loading of exception classes not susceptible to interference in a folder below system/application.

In case you want to dup:

1. Create a blank web app from CI 1.7.
2. Create a simple controller that echoes hello world. Confirm that it works.
3. Create system/application/libraries/Exceptions.php. It can be totally blank.
4. Run again. Should still work.
5. Now create an error in your controller. I either removed a $ from a variable name, or tried to require_once on a file that didn't exist.
6. Re-run the controller; you should see the error I reported.
7. Rename the Exceptions.php file to some other name; you should see normal CI errors.
#5

[eluser]Pascal Kriete[/eluser]
Yeah, this is expected behavior. The reason is hidden in creating core classes. You can override CodeIgniter classes with your own without changing the core. So this is actually more of a feature than it is a bug Smile .




Theme © iAndrew 2016 - Forum software by © MyBB