From 2fe98d4957ee82c9f63ed3fa7a9f23de90fb7318 Mon Sep 17 00:00:00 2001 From: lkorth Date: Thu, 21 Apr 2016 10:05:20 -0400 Subject: [PATCH] Return rate limit message instead of parsing error stream --- .../com/braintreepayments/api/internal/HttpClientTest.java | 4 ++-- .../java/com/braintreepayments/api/internal/HttpClient.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/src/androidTest/java/com/braintreepayments/api/internal/HttpClientTest.java b/Core/src/androidTest/java/com/braintreepayments/api/internal/HttpClientTest.java index 17a6e56383..4b48862e3d 100644 --- a/Core/src/androidTest/java/com/braintreepayments/api/internal/HttpClientTest.java +++ b/Core/src/androidTest/java/com/braintreepayments/api/internal/HttpClientTest.java @@ -352,9 +352,9 @@ public void postsUnprocessableEntityExceptionOn422() throws IOException, Interru @Test(timeout = 1000) public void postsRateLimitExceptionOn429() throws IOException, InterruptedException { - HttpClient httpClient = clientWithExpectedResponse(429, "Too many requests"); + HttpClient httpClient = clientWithExpectedResponse(429, ""); - assertExceptionIsPosted(httpClient, RateLimitException.class, "Too many requests"); + assertExceptionIsPosted(httpClient, RateLimitException.class, "You are being rate-limited. Please try again in a few minutes."); } @Test(timeout = 1000) diff --git a/Core/src/main/java/com/braintreepayments/api/internal/HttpClient.java b/Core/src/main/java/com/braintreepayments/api/internal/HttpClient.java index ee667fb4e6..59aaa3a2ba 100644 --- a/Core/src/main/java/com/braintreepayments/api/internal/HttpClient.java +++ b/Core/src/main/java/com/braintreepayments/api/internal/HttpClient.java @@ -249,7 +249,7 @@ protected String parseResponse(HttpURLConnection connection) throws Exception { case 426: // HTTP_UPGRADE_REQUIRED throw new UpgradeRequiredException(readStream(connection.getErrorStream(), gzip)); case 429: // HTTP_TOO_MANY_REQUESTS - throw new RateLimitException(readStream(connection.getErrorStream(), gzip)); + throw new RateLimitException("You are being rate-limited. Please try again in a few minutes."); case HTTP_INTERNAL_ERROR: throw new ServerException(readStream(connection.getErrorStream(), gzip)); case HTTP_UNAVAILABLE: