Skip to content

Commit

Permalink
feat(cf): provide more info when retrying an API (#4137)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy Louie authored and mergify[bot] committed Oct 31, 2019
1 parent 0b09b4c commit 41fe840
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public void intercept(RequestFacade request) {
};

private static class RetryableApiException extends RuntimeException {
RetryableApiException() {
super();
RetryableApiException(String message) {
super(message);
}

RetryableApiException(String message, Throwable cause) {
Expand Down Expand Up @@ -158,13 +158,19 @@ Response createRetryInterceptor(Interceptor.Chain chain) {
case 504:
// after retries fail, the response body for these status codes will get wrapped up
// into a CloudFoundryApiException
throw new RetryableApiException();
throw new RetryableApiException(
"Response Code "
+ response.code()
+ ": "
+ chain.request().httpUrl()
+ " attempting retry");
}

return response;
});
} catch (SocketTimeoutException e) {
throw new RetryableApiException("Timeout " + callName, e);
throw new RetryableApiException(
"Timeout " + callName + " " + chain.request().httpUrl() + ", attempting retrying", e);
} catch (Exception e) {
final Response response = lastResponse.get();
if (response == null) {
Expand Down

0 comments on commit 41fe840

Please sign in to comment.