Re: PHP5: PEAR base Exception classes
| From: | Tobias Schlitt | Date: | Thu, 17 Jun 2004 13:25:38 +0000 |
| Subject: | Re: PHP5: PEAR base Exception classes | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30864@lists.php.net to get a copy of this message | ||
Hi Hans! You wrote:
> I think it would be great if PEAR provided some re-usable base Exception
> classes.
I posted this idea a few weeks/moths (dunno) ago...
I see a huge benefit in having such a class, since people then can catch any
PEARException, if they want to, to just indicate that an exceptional state
occured inside a PEAR class.
> Would there be an 'exceptions' package?
I don't think that this is the way to go. A base exception class should be
included in the PERA package. Making a new package and generating new
dependencies sounds overhead to me.
> I don't see any need
> to prefix these w/ a category name, though, since they'd be generic:
>
> I'm thinking in particular of having a few different extension
> categories that PHP5 packages *may* use if desired, e.g.:
>
> - IOException
> - MathException
> - ... (I'm sure there are many others)
This can be decided from category to category, I think, but in this case,
new packages would be needed and new dependencies would raise. Having just a
basic exception class and on package basis derived exception classes should
be ok.
> I don't think that every package needs its own Extensions, but in some
> cases a given package will want to be able to selectively throw
> different categories for handling by the calling code. Exceptions
> become useful when you can use hierarchies & selectively catch. Again,
> classes could always throw the base Exception object if desired.
Ack.
> In addition to the categories, there are some Exception features that
> would be very nice, for example:
> - NestableException
> This is an Exception that allows you to wrap an existing Exception and
> re-throw it without losing any info from the original. This would be
> particularly useful for PEAR & should be a base class for the other
> Exception types IMO.
> How does one propose code that goes into core PEAR? I imagine that this
> would be in something like an 'exception/' dir, but, again, I don't see
> any reason to add a prefix as that would be completely redundant (and
> make using them just more cumbersome).
I did not really get that point. Can you explain it once more to me?
Regards,
Toby
--
Tobias Schlitt
a passion for php http://www.schlitt.info