diff options
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; + } } } |