Re: Emulating Java Exceptions

From: Date: Sun, 14 Jul 2002 05:17:52 +0000
Subject: Re: Emulating Java Exceptions
Groups: php.general 
Request: Send a blank email to php-general+get-107573@lists.php.net to get a copy of this message
>Hi All, > >I'm porting Java Code to PHP, my question is: What is the best approach >to emulate Java exceptions in PHP4? (I know ZE2 adds exceptions but I >can't wait). > >When a Java method "throws" an exception it is difficult to handle as a >"return" of an exception object since then I'd have to check in every >sinlge line that calls a method if the returned value is an exception >and then return and exception etc etc. (Chaning that up to the user >would be a nightmare). > >So I need some clever ideas ;-) http://php.net/set_error_handler http://php.net/trigger_error http://php.net/error_log Pretty much, take those and a little discipline with your programming staff, and you're done... Maybe write some kind of error message system that creates a unique ID for each error message. You can wrap it up in some Objects if that makes you happy. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#107573) next »