Re: Feedback from Drupal
| From: | Greg Beaver | Date: | Wed, 03 Jun 2009 13:46:04 +0000 |
| Subject: | Re: Feedback from Drupal | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-43@lists.php.net to get a copy of this message | ||
Larry Garfield wrote:
> **Exceptions and Exception Handling**
> Each package must provide a base exception of the following name:
> vendor\package\Exception
>
> This exception may be either an interface or class (concrete or
> abstract). Each exception thrown by "vendor\package" must throw
> exceptions that either extend or implement this base exception.
> ***********************************
>
> I've read the follow-ups here, and frankly, um, I still don't get it. Why
> must that exist? What's the benefit? Granted I am not working in a heavily OO
> and exception-using world, but I still don't understand what the advantage is
> here.
>
> And no mention of naming conventions for exceptions, such as
> FooBarBazException? I'd have expected to see that in there. :-)
Quick note:
it allows a catch-all for a specific 3rd-party package, which can speed
safe development:
try {
$a = new thirdparty\Thingy;
$a->doSomething();
$b = new anotherthirdparty\Thingy;
$b->doSomething();
} catch (thirdparty\Thingy\Exception $e) {
} catch (anotherthirdparty\Thingy\Exception $e) {
}
otherwise, it can be impossible to know where an exception originates
without parsing the error message (nasty yucky).
Greg
P.S. I think Larry's/Brian's points about procedural standards is reason
enough to keep the list open if this will be useful for these projects.