Re: Emulating Java Exceptions

From: Date: Fri, 12 Jul 2002 14:47:31 +0000
Subject: Re: Emulating Java Exceptions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-107376@lists.php.net to get a copy of this message
Alberto, I might have expressed the problem wrongly, if you have lets suposse you have: $obj = new foo(); $obj->some(); And some might return an "exception" object. The problem is that some may call a lot of other methods from foo and I don't want to check if the return value of each method call is an exception. Example: function some() { $x = $this->other_method(); } If other_method produces an exception then I want the exception returned directly to the "some" caller without the need to check in the "Some" method if "other_method" returned a normal "x" or an exception object... Alberto Serra wrote:
Привет! Garland Foster wrote:
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).
If the exceptions you have to manage are code generated at runtime you actually may simply write your own manager. Have a root class with a method called Function exception($yourparms) { treat exception here; } Game over, since everybody inherits from your root class you can manage whatever you want your own way. It's objects, so work in OO and forget about java lingo. Mind you, it won't manage a parse error, that's for sure. Пока Альберто Киев @-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@ LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu? lOrD i'M sHiNiNg... YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE tHe TeSt, YeS iT iS ThE tEsT, yEs It Is tHe TeSt, YeS iT iS ThE tEsT, yEs It Is.......


« previous php.general (#107376) next »