Re: exceptions
| From: | Justin Patrin | Date: | Wed, 09 Jun 2004 18:15:01 +0000 |
| Subject: | Re: exceptions | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30311@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
Justin Patrin wrote:I suppose, but, as has been said before, PEAR_ErrorStack is meant to replace PEAR_Error and is smaller and better. Also, as has been said before in this thread, Exceptions are thought more to be for major errors, whereas smaller errors or warnings could be returned. Even if you use Exceptions only, I would think that in PEAR there may be a special Exception class with more data than the normal one. An external dependency is not a problem...many (most) PEAR packages have an external dependency of some kind.Bertrand Mansion wrote:OK. Things to take into consideration are: - If you use PEAR_Error, you add an external dependency to your package whereas exceptions are bundled in PHP5. I have had some requests for a PEAR free HTML_QuickForm, so exceptions are interesting in this case.Can't we just get rid of PEAR_Error and use exceptions instead ? Bertrand Mansion MamasamI assume you haven't read all of the other posts saying that we can't force exceptions or errors. Exceptions are one way of handling things and returning errors is another. "Exceptions are only supposed to be used for exceptional circumstances." Whether or not you believe that, using exceptions or returning errors is a design question and we don't want to force developers to use one or the other. Read the rest of the thread for more discussion.
- Returning a PEAR_Error object is IMO heavier than throwing an exception because of all the overhead it adds.Sure, PEAR_Error is a bit heavy, but PEAR_ErrorStack is lighter. And as I've said, I would be in favor of a specialized Exception class for PEAR that includes the same kind of data that PEAR_Error does and have at least some of the same functionality.
I would be interested to know how many people know about exceptions and use them in their code already and what for.-- paperCrane <Justin Patrin>