Re: Exception misinformation

From: Date: Sun, 11 Jul 2004 19:53:29 +0000
Subject: Re: Exception misinformation
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-31856@lists.php.net to get a copy of this message
Mandate that PEAR Exceptions get thrown by a PEAR method. Instead of: throw new SomeFangledException('aha'); Developers should write: PEAR_Exception::throw(new SomeFangledException('aha')); You can then do all kinds of magic, from silencing to downgrading into Warnings. This has at least one defect: the stack trace for the exception will start inside PEAR_Exception::throw. The first meaningful location will the the next level in the call stack. Complicating a bit the throwing code, one could mandate PEAR_Exceptions are thrown like this: if (PEAR_Exception::shouldThrow($e = new SomeFangledException('aha')))
    throw(e);
Cheers, Sérgio Carvalho Lukas Smith wrote:
Hi, I am wondering if we have come up with some magic to handle the following issue with exceptions. Currently using PEAR_Error I can build up a stack of expected errors which should not cause the standard error handling callback to be called and thereby let local error handling take over. The only way using Exceptions I can quickly come up with is wrapping every method call with a try catch block including _every_ method call. Considering that this catch block could get fairly lengthy this could bloat code considerably. Again this shows a huge problem in how exceptions force handling of every error and at the same time not being able to be easily selectively suppresed from showing this behaviour. Anyways not sure that I thought this thing 100% through considering its a sunday evening and I am currently watching a movie on TV. If I am totaly off .. sorry for the noise. regards, Lukas


Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.pear.dev (#31856) next »