diff options
author | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-22 14:47:03 +0200 |
---|---|---|
committer | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-22 14:47:03 +0200 |
commit | 2b2a47a0086eab52b09e5425e75cafb488e51074 (patch) | |
tree | 5ea244f904d4a9ce9855133ec3df4f06f8b7c95a /src/io/OAuthRequester.java | |
parent | b318cc755befd04f711c03f927789fc8c1a72216 (diff) | |
download | TwitterDataAnalytics-2b2a47a0086eab52b09e5425e75cafb488e51074.tar.gz |
Updated the Requesters to throw RateLimitException.
* The exception contains the reset timestamp in unix time.
Diffstat (limited to 'src/io/OAuthRequester.java')
-rw-r--r-- | src/io/OAuthRequester.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/io/OAuthRequester.java b/src/io/OAuthRequester.java index 3621186..9cde429 100644 --- a/src/io/OAuthRequester.java +++ b/src/io/OAuthRequester.java @@ -3,6 +3,8 @@ package io; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URLConnection; +import java.util.logging.Level; +import java.util.logging.Logger; import oauth.signpost.OAuth; import oauth.signpost.OAuthConsumer; import oauth.signpost.basic.DefaultOAuthConsumer; @@ -136,7 +138,12 @@ public class OAuthRequester extends AbstractRequester { public boolean isValid() throws IOException { // NOTE: this actually contributes to the ratelimit (12/minute) // TODO: find alternative that does not hit the ratelimit - Response obj = getJSON("application/rate_limit_status"); - return !obj.getResp().getAsJsonObject().has("errors"); + Response obj; + try { + obj = getJSON("application/rate_limit_status"); + return !obj.getResp().getAsJsonObject().has("errors"); + } catch (RateLimitException ex) { + return false; + } } } |