Skip to content

Commit f022fcb

Browse files
committed
Added retryable errors.
1 parent 02d4336 commit f022fcb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,41 @@
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(404, null),
35+
new Error(409, null),
36+
new Error(500, null),
37+
new Error(502, null),
38+
new Error(503, null));
3039
private static final long serialVersionUID = 490302380416260252L;
3140

3241
public DnsException(IOException exception) {
3342
super(exception, true);
3443
}
3544

36-
public DnsException(int code, String message) {
45+
private DnsException(int code, String message) {
3746
super(code, message, null, true);
3847
}
3948

49+
@Override
50+
protected Set<Error> retryableErrors() {
51+
return RETRYABLE_ERRORS;
52+
}
53+
4054
/**
4155
* Translate RetryHelperException to the DnsException that caused the error. This method will
4256
* always throw an exception.
@@ -48,6 +62,4 @@ static DnsException translateAndThrow(RetryHelperException ex) {
4862
BaseServiceException.translateAndPropagateIfPossible(ex);
4963
throw new DnsException(UNKNOWN_CODE, ex.getMessage());
5064
}
51-
52-
//TODO(mderka) Add translation and retry functionality. Created issue #593.
5365
}

0 commit comments

Comments
 (0)