Re: Exception Questions (HTTP_Request2 & Services_Digg2)

From: Date: Sat, 12 Jun 2010 20:50:09 +0000
Subject: Re: Exception Questions (HTTP_Request2 & Services_Digg2)
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-53559@lists.php.net to get a copy of this message
Hi Steve, On 10.06.2010 17:46, Steve Williams wrote:
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)"
If you are using Curl adapter then it can also be whatever error message curl itself returns.
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?
There is a feature request open for HTTP_Request2: http://pear.php.net/bugs/bug.php?id=16762 The problem is proper mapping of error codes and messages returned by curl, stream_socket_client(), etc.

« previous php.pear.dev (#53559) next »