RE: [PEAR-DEV] Some more PHP5-related ruminations: Exceptions

From: Date: Tue, 08 Apr 2003 01:22:16 +0000
Subject: RE: [PEAR-DEV] Some more PHP5-related ruminations: Exceptions
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15009@lists.php.net to get a copy of this message
Hi Hans, --- Hans Lellelid <hans@appliedsec.com> wrote: > > > > The execptions in PHP5 look nice, and should make some of the > > error handling simpler and more consistent. > > > > One thing that the Exception class does not have is the > > ability to chain them. Tried subclassing it but did not work > > too well (the filename and line were always wrong), > > The reason the FILE & LINE were wrong is that they are set by PHP5's > Exception constructor ... So if Exception::Exception() is called by your > subclass, the file & line will be set from the subclass' constructor. > > To avoid this just don't override the exception constructor. Use things > like setCode(), setDebugInfo() instead of expanding the constructor > signature. > > So, this will work: > > $exc = new SQLException(); // File & line set from this point > $exc->setNativeError(mysql_error()); > throw $exc; That is an idea. Just one more method to setup the chained/subexception then. Simple and quick. Tnxs for the info. ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com

« previous php.pear.dev (#15009) next »