Re: My Experience with PHP5 Error Handling (and possible

From: Date: Thu, 26 Aug 2004 16:01:11 +0000
Subject: Re: My Experience with PHP5 Error Handling (and possible
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-32964@lists.php.net to get a copy of this message
Sergio Carvalho wrote:
Davey wrote:
eeeeeeeeeew. Sorry, thats ugly, its a waste of resources to instantiate so many classes and extending Exception everytime which gives you the getCode()... no, bad idea, sorry. Stick to using exceptions as they should be, the name for the package, and $exception->getCode() for the error code (which can then be used to get messages or whatever you want to associate with it. Think of it as a primary key from which you can get all the other error details - this is what PEAR_Exception has to decide on - what information we put into the exception)
No, Greg described exactly how Exceptions should be used. Unless you come up with hard numbers proving that defining classes to /classify/ errors introduces severe overhead, your opinion falls on the group of early optimization errors. Exception class hierarchies are way richer and descriptive than error code flat categorization. Cheers, Sérgio Carvalho
Plus it allows you to use a big exception feature. try { ... } Catch (SqlWarning $e) { // log } Catch (SqlFail $e) { // produce an error message for the user } Instead of catching things and then doing a switch or whatever. It also allows you to just ignore say warnings and let your default exception handler grab them if you want. Plus the only performance problem I see its lots of tiny file and there is an easy fix to that. Just use one file. -josh btw: hopefully that syntax is correct in php5, most of my exception experience comes from java

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