Skip to content

Commit 9b6929b

Browse files
committed
Added retryable errors.
1 parent fa081ac commit 9b6929b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,39 @@
1616

1717
package com.google.gcloud.dns;
1818

19+
import com.google.common.collect.ImmutableSet;
1920
import com.google.gcloud.BaseServiceException;
2021
import com.google.gcloud.RetryHelper.RetryHelperException;
2122
import com.google.gcloud.RetryHelper.RetryInterruptedException;
2223

2324
import java.io.IOException;
25+
import java.util.Set;
2426

2527
/**
2628
* DNS service exception.
2729
*/
2830
public class DnsException extends BaseServiceException {
2931

32+
// see: https://cloud.google.com/dns/troubleshooting
33+
private static final Set<Error> RETRYABLE_ERRORS = ImmutableSet.of(
34+
new Error(500, null),
35+
new Error(502, null),
36+
new Error(503, null));
3037
private static final long serialVersionUID = 490302380416260252L;
3138

3239
public DnsException(IOException exception) {
3340
super(exception, true);
3441
}
3542

36-
public DnsException(int code, String message) {
43+
private DnsException(int code, String message) {
3744
super(code, message, null, true);
3845
}
3946

47+
@Override
48+
protected Set<Error> retryableErrors() {
49+
return RETRYABLE_ERRORS;
50+
}
51+
4052
/**
4153
* Translate RetryHelperException to the DnsException that caused the error. This method will
4254
* always throw an exception.
@@ -48,6 +60,4 @@ static DnsException translateAndThrow(RetryHelperException ex) {
4860
BaseServiceException.translateAndPropagateIfPossible(ex);
4961
throw new DnsException(UNKNOWN_CODE, ex.getMessage());
5062
}
51-
52-
//TODO(mderka) Add translation and retry functionality. Created issue #593.
5363
}

0 commit comments

Comments
 (0)