Uncaught Exception when Twitter API is experiencing an outage
Closed this issue · 4 comments
Jaisen,
First, this thing is great and has saved me a zillion hours in coding, so thanks!
I'm experiencing an issue right now with the API throwing an uncaught exception when the Twitter API is having a service outage. The only time I'd seen this problem before is if I were using a bad consumer key/secret/etc. However, I know all that info is right. But now my site is throwing the following error:
Fatal error: Uncaught exception 'EpiOAuthException' in /usr/local/apache2.2.8/sites/swstage/htdocs/libraries/Twitter/EpiOAuth.php:434
Stack trace:
#0 /usr/local/apache2.2.8/sites/swstage/htdocs/libraries/Twitter/EpiOAuth.php(404): EpiOAuthException::raise(Object(EpiCurlManager), false)
#1 /usr/local/apache2.2.8/sites/swstage/htdocs/libraries/Twitter/EpiOAuth.php(45): EpiOAuthResponse->__get('oauth_token')
#2 /usr/local/apache2.2.8/sites/swstage/htdocs/index.php(89): EpiOAuth->getAuthenticateUrl()
#3 {main}
thrown in /usr/local/apache2.2.8/sites/swstage/htdocs/libraries/Twitter/EpiOAuth.php on line 434
I went to the API health page for Twitter, and confirmed that they're having a service interruption. So the question is, what I can I do to have this die more gracefully when this happens in the future?
Thanks!
Mike
Does wrapping your EpiTwitter code inside of a try/catch work? You should
probably do that anyway because exceptions are thrown by the library when
you get a non 2xx response code.
That was my first idea too, but I wasn't sure if it was necessary. Is there a specific type of exception it'll throw, or should I just catch a generic Exception $foo ?
Thanks for the quick response!
--- On Thu, 6/21/12, Jaisen Mathai reply@reply.github.com wrote:
From: Jaisen Mathai reply@reply.github.com
Subject: Re: [twitter-async] Uncaught Exception when Twitter API is experiencing an outage (#149)
To: "michaelbelt" michaelbelt@yahoo.com
Date: Thursday, June 21, 2012, 2:42 PM
Does wrapping your EpiTwitter code
inside of a try/catch work? You should
probably do that anyway because exceptions are thrown by the
library when
you get a non 2xx response code.
Reply to this email directly or view it on GitHub:
#149 (comment)
You can do something like...
try
{
// your code
}
catch(EpiTwitterException $e)
{
// known errors
}
catch(Exception $e)
{
// unknown errors
}
On Fri, Jun 22, 2012 at 7:37 AM, michaelbelt <
reply@reply.github.com
wrote:
That was my first idea too, but I wasn't sure if it was necessary. Is
there a specific type of exception it'll throw, or should I just catch a
generic Exception $foo ?Thanks for the quick response!
--- On Thu, 6/21/12, Jaisen Mathai reply@reply.github.com wrote:
From: Jaisen Mathai reply@reply.github.com
Subject: Re: [twitter-async] Uncaught Exception when Twitter API is
experiencing an outage (#149)
To: "michaelbelt" michaelbelt@yahoo.com
Date: Thursday, June 21, 2012, 2:42 PM
Does wrapping your EpiTwitter code
inside of a try/catch work? You should
probably do that anyway because exceptions are thrown by the
library when
you get a non 2xx response code.
Reply to this email directly or view it on GitHub:
#149 (comment)
Reply to this email directly or view it on GitHub:
#149 (comment)
That's more or less what I was thinking, thanks for the quick reply!
--- On Fri, 6/22/12, Jaisen Mathai reply@reply.github.com wrote:
From: Jaisen Mathai reply@reply.github.com
Subject: Re: [twitter-async] Uncaught Exception when Twitter API is experiencing an outage (#149)
To: "michaelbelt" michaelbelt@yahoo.com
Date: Friday, June 22, 2012, 12:14 PM
You can do something like...try
{
// your code
}
catch(EpiTwitterException $e)
{
// known errors
}
catch(Exception $e)
{
// unknown errors
}On Fri, Jun 22, 2012 at 7:37 AM, michaelbelt <
reply@reply.github.comwrote:
That was my first idea too, but I wasn't sure if it was
necessary. Is
there a specific type of exception it'll throw, or
should I just catch a
generic Exception $foo ?Thanks for the quick response!
--- On Thu, 6/21/12, Jaisen Mathai reply@reply.github.com
wrote:From: Jaisen Mathai reply@reply.github.com
Subject: Re: [twitter-async] Uncaught Exception
when Twitter API is
experiencing an outage (#149)
To: "michaelbelt" michaelbelt@yahoo.com
Date: Thursday, June 21, 2012, 2:42 PM
Does wrapping your EpiTwitter code
inside of a try/catch work? You should
probably do that anyway because exceptions are
thrown by the
library when
you get a non 2xx response code.
Reply to this email directly or view it on
GitHub:
#149 (comment)
Reply to this email directly or view it on GitHub:
#149 (comment)
Reply to this email directly or view it on GitHub:
#149 (comment)