Page 1 of 1

set_error_handler and error supression

Posted: Tue Feb 12, 2008 8:58 am
by shiznatix
Ok so here's the deal. I have a custom error handler that I use to send myself an email every time there is an error of any sort (E_ALL). Now this was great because it would help me find small bugs in my code that might have seeped through or even let me know that mysql went down for whatever reason...blah blah blah.

Now I switched to the Zend Framework and it uses some error suppressing when trying to load the Controller class. This is because sometimes the controller file won't be there because maybe its a "file not found" page or something. Anyway, I have a plugin that redirects all of these unknown controller requests to a custom file not found page. Great. Awesome. The problem is that there is a @fopen() call which basically returns false because the file does not exist. When the file does not exist, I get an email saying "file does not exist" and im sitting here going "i know!!!!".

So is there a way to get errors that are suppressed like that to not go into my custom error handler? These are the only emails I do not care about and I am getting a million of them.

Re: set_error_handler and error supression

Posted: Tue Feb 12, 2008 9:29 am
by superdezign
Have you tried getting rid of that call since it will always return false?

Re: set_error_handler and error supression

Posted: Tue Feb 12, 2008 10:37 am
by Christopher
Why not just edit the Zend controller file and remove the @. It might be a pain, but you only need to do it when you install or upgraded.

Re: set_error_handler and error supression

Posted: Tue Feb 12, 2008 2:40 pm
by shiznatix
ok i found the solution actually but don't quite know how to use it yet. I will look into it more tomorrow but if anyone wanted to know it is here:
It is important to remember that the standard PHP error handler is completely bypassed. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.