Email notifications to developer with errors (php errors) |
[eluser]seba22[/eluser]
Hello, First i would like to tell You something, few days back i had problem with my application with many ajax functions / requests... It can work for all day without any errors, but if some conditions was made.... baam... we have php error what break json response, and this lead to death of ajax site ![]() I spend few days trying to find what's wrong.... i was unable to reproduce on my browser with firebug... because of that conditions... i found error by myself by checking php code line by line ;-) When error is at main page, user can just contact tech support, send email with output etc, but when it's inside /soemthing/api.php?action=xyz?vlaue=asd hes unable to figure out what's wrong... Basically that was the moment where i start asking myself "is there any class what will send email with php errors to specified e-mail address" before throwing them to user ? I see, that Codeigniter errors, are not PHP default, there are somehow nice formatted... thats led me to a question: Is there something suitable build inside Codeigniter what will email me an errors, before showing them to user ? Regards
[eluser]InsiteFX[/eluser]
You could extend the Exceptions Class. See: Code: system/core/Exceptions.php Simple Way To Add Global Exception Handling In CodeIgniter
[eluser]seba22[/eluser]
Hello, Thank You for answering my question. I follow tutorial above, but i end with Code: Fatal error: Class 'CI_Exceptions' not found in... I do some readings on my own, and i found answer that i should create "MY_Exceptions.php" inside "application/libraries/MY_Exceptions.php" I have done this: I put code from tutorial Code: <? Of course i change my e-mail. Then i create "fake" error message by typing Code: print($xyzzaas['asd']); Inside my controller I run my code, and get "error" Code: A PHP Error was encountered So i check my e-mail... and got nothing. Next i edit up Code: class MY_Exceptions extends CI_Exceptions { But this email also did not come... I think that file wont called. I'm running Codeigniter 2.1.3 If anyone know what i done wrong, please tell me ;-)
[eluser]seba22[/eluser]
Hello, I found answer why it's not being called. You have put "MY_Exceptions.php" to "/application/core" And following working code: Code: <? I have change Code: parent::CI_Exceptions(); Code: parent::__construct(); Above full code is working. What about Code: class ExceptionHook How test this errors ? Regards |
Welcome Guest, Not a member yet? Register Sign In |