Re: PEAR, PHP5 and Exceptions
| From: | Hans Lellelid | Date: | Thu, 17 Jun 2004 11:20:01 +0000 |
| Subject: | Re: PEAR, PHP5 and Exceptions | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30852@lists.php.net to get a copy of this message | ||
Michael Wallner wrote:
Hi, With the assumption in mind that many PEAR devs fear PHP5s Exceptions I wrote a tiny package, which let you handle Exceptions just like PEAR_Errors if you want to. As far as I'm concerened we wouldn't need that at all if we would just use Exceptions for PHP5 packages.Yeah, I'd think not for PHP5, but it's certainly interesting! On a less related note, but I think belonging to this thread topic, I think it would be great if PEAR provided some re-usable base Exception classes. Would there be an 'exceptions' package? 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) 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. 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). Hans