Exception Questions (HTTP_Request2 & Services_Digg2)
| From: | Steve Williams | Date: | Thu, 10 Jun 2010 13:46:58 +0000 |
| Subject: | Exception Questions (HTTP_Request2 & Services_Digg2) | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-53553@lists.php.net to get a copy of this message | ||
In the PEAR coding standards, I don't see any requirement to include a numeric code when throwing exceptions. Nor to throw an error-specific exception subclass.
http://pear.php.net/manual/en/standards.errors.php
Indeed, HTTP_Request2 throws exceptions with only a textual description.
So how might I write code to catch and recover from specific errors? For example, HTTP_Request2::send() can throw HTTP_Request2_Exception with:
- "Error writing request"
- "Request timed out after N second(s)"
I'd like my app to recover from the timeout but re-throw the other error.
Am I missing how to do that? Should PEAR packages use numerical error codes to allow that? Or error-specific exception subclasses?
Bill Shupp, a related question: Services_Digg2 bubbles up HTTP_Request2 exceptions, which would seem to violate:
"Exceptions should be bubbled up, except (when the) original exception is from another package. Letting it bubble up would cause implementation details to be exposed, violating layer abstraction, conducing to poor design."
Do I misunderstand the intent of the coding standards?