Re: Re: Error recovery - fatal errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16 May 2011 22:14, Tim Streater <tim@xxxxxxxxxxxxxxxx> wrote:
> On 14 May 2011 at 15:05, Peter Lind <peter.e.lind@xxxxxxxxx> wrote:
>
>> On 14 May 2011 12:33, Tim Streater <tim@xxxxxxxxxxxxxxxx> wrote:
>>> I would like, in my app, to recover from as many run-time errors as possible,
>>> so that I can tidy up. And unsolicited output generated by the standard error
>>> system is really unhelpful as it becomes part of the ajax reply to the
>>> browser.
>>>
>>> So I've added my own error handler, but it seems that I can't catch fatal
>>> errors. The error in question comes from doing something like:
>>
>> Fatal errors are fatal - if you could recover from them, they wouldn't be
>> fatal.
>
> Except that this error is arbitrarily designated as fatal when it need not be. A few days ago I discovered register_shutdown_function as mentioned by someone today, and use that to pass E_ERRORs on to my error handler (as declared by set_error_handler). That way I can log the error properly and notify the user in a consistent manner. I've tested this by introducing some errors (e.g. unitialised variables or setting $dbh to null) and these are all nicely picked up.

You were trying to call a method on a non-object - how do you expect
PHP to handle that if not with a fatal error?
Anyway, good to hear you solved the issue - I misunderstood what you
wanted to do (shut down in a proper fashion, not actually recover from
the error) so I didn't think to mention this.

* snip *

>> You can avoid all problems with error output by turning off error
>> displays in php.ini (set display_errors = off) - use error logging
>> instead. That's the recommended setting for production servers.
>
> This is not a browser/webserver situation in the classic manner. In this case, the browser, PHP code, and the instance of apache used are all running on the user's machine. The user just thinks they are running a local application.

You can call it production server or not, if you are having problems
with error messages from php then you should turn off error display -
which shouldn't get in the way of you showing your own error messages
but will solve the problem mentioned.

Regards
Peter

-- 
<hype>
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
</hype>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux