Req #17501 [Opn]: Exception subclasses so I can catch and suppress timeout errors
| From: | izi@php.net | Date: | Thu, 17 Jun 2010 18:16:07 +0000 |
| Subject: | Req #17501 [Opn]: Exception subclasses so I can catch and suppress timeout errors | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-3952@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=17501&edit=1
ID: 17501
Updated by: izi@php.net
Reported By: mike at silverorange dot com
Summary: Exception subclasses so I can catch and suppress
timeout errors
Status: Open
Type: Feature/Change Request
Package: Services_Twitter
Package Version: 0.6.1
PHP Version: Irrelevant
Roadmap Versions:
New Comment:
Hi Mike,
>> Prior to version 0.6.x of Services_Twitter, I caught
>> Services_Twitter_Exception and matched its
>> error message against a regular expression to detect timeouts.
err ! that's always a bad idea :p
>> In Version 0.6.x, the error message text changed
>> so my regular expression no longer matched.
In fact, Services_Twitter throws an exception with the code and message
returned by the twitter API, so the message was changed upstream...
Can't you match the error with the exception code ?
http://apiwiki.twitter.com/HTTP-Response-Codes-and-Errors
That said, a timeout is more likely to be thrown by http_request2, and
in this case Services_Twitter gives you the ability to retrieve the
original http_request2 exception.
>> It would be nice if Services_Twitter threw more specific
>> exception types so errors could be handled differently
>> depending on what went wrong
I'm not sure this is a good idea as we would end doing the same thing
you are doing (ie. parsing messages or http codes...). Services_Twitter
currently gives the ability to distinguish all http error code and
messages returned by the API via $exception->getCode(), I think it's
enough.
Regards,
--
David
Previous Comments:
------------------------------------------------------------------------
[2010-06-17 17:50:56] gauthierm
Description:
------------
Prior to version 0.6.x of Services_Twitter, I caught
Services_Twitter_Exception and matched its error message
against a regular expression to detect timeouts.
In Version 0.6.x, the error message text changed so my
regular expression no longer matched.
It would be nice if Services_Twitter threw more specific
exception types so errors could be handled differently
depending on what went wrong.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=17501&edit=1