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/BearerRequester.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/BearerRequester.java')
-rw-r--r-- | src/io/BearerRequester.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/io/BearerRequester.java b/src/io/BearerRequester.java index 11776fc..8af38f8 100644 --- a/src/io/BearerRequester.java +++ b/src/io/BearerRequester.java @@ -1,14 +1,13 @@ package io; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.io.Charsets; -import org.json.JSONException; -import org.json.JSONObject; import support.ConsumerKeySecret; /** @@ -88,9 +87,13 @@ public class BearerRequester extends AbstractRequester { @Override 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"); + try { + // 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"); + } catch (RateLimitException ex) { + return false; + } } } |