Skip to content

Commit

Permalink
supdev GiKIgqnO - Throw BraintreeTimeoutException when request times out
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Mar 2, 2016
1 parent 765029c commit 78e755a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.braintreegateway.exceptions;

public class TimeoutException extends BraintreeException {
private static final long serialVersionUID = 1L;

public TimeoutException(String message) {
super(message);
}

public TimeoutException(String message, Throwable cause) {
super(message, cause);
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/braintreegateway/util/Http.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLDecoder;
import java.security.KeyStore;
Expand Down Expand Up @@ -36,6 +37,7 @@
import com.braintreegateway.exceptions.DownForMaintenanceException;
import com.braintreegateway.exceptions.NotFoundException;
import com.braintreegateway.exceptions.ServerException;
import com.braintreegateway.exceptions.TimeoutException;
import com.braintreegateway.exceptions.UnexpectedException;
import com.braintreegateway.exceptions.UpgradeRequiredException;
import com.braintreegateway.org.apache.commons.codec.binary.Base64;
Expand Down Expand Up @@ -140,6 +142,8 @@ private NodeWrapper httpRequest(RequestMethod requestMethod, String url, String
responseStream.close();
}
}
} catch (SocketTimeoutException e) {
throw new TimeoutException(e.getMessage(), e);
} catch (IOException e) {
throw new UnexpectedException(e.getMessage(), e);
} finally {
Expand Down

0 comments on commit 78e755a

Please sign in to comment.