Re: Best error handling

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

 



Davi Ramos wrote:
Hi. I have a kind of webserver that certain applications communicate with.
The problem is that the script (named peer.php) must output data as xml.
Thats ok (thanks to XMLWriter). The problem is that when some error occurs
(those note catchable by set_error_handler) I have no control on data being
outputed.

I would like to output xml even on fatal errors (in that case, telling that
something gone wrong). I tried using register_shutdown_function but it is
crashing (as the nature of fatal errors that make the envirionment
unstable).

Any idea?

Thanks!


not a nice answer but make sure you're application has no fatal errors - a fatal error halts the compiler as it's fatal, thus there is no way to implement anything else afterwards or turn it in to an exception or suchlike.

further, for live servers you really should have display errors set to off in you're php.ini - at which point nothing will be returned

try: (not tested or particularly thought about)
1: move all the code from peer.php in to an include file
2: make you're main peer.php file contain only
<?php
try {
 require_once 'include_file.php';
} catch($e) {
echo 'some xml error';
}
?>

can't promise that'll work though, to test quickly just add all that to a php file and run it (as you don't have the required file so a fatal will get raised)

regards and good luck - nathan

ps: may check this one out myself, sure I've done it years ago when i still made sites

--
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