summaryrefslogtreecommitdiff
path: root/src/io/BearerRequester.java
diff options
context:
space:
mode:
authorMaurice Laveaux <m.laveaux@student.tue.nl>2014-05-22 14:47:03 +0200
committerMaurice Laveaux <m.laveaux@student.tue.nl>2014-05-22 14:47:03 +0200
commit2b2a47a0086eab52b09e5425e75cafb488e51074 (patch)
tree5ea244f904d4a9ce9855133ec3df4f06f8b7c95a /src/io/BearerRequester.java
parentb318cc755befd04f711c03f927789fc8c1a72216 (diff)
downloadTwitterDataAnalytics-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.java17
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;
+ }
}
}