1616
1717package com .google .gcloud .dns ;
1818
19+ import com .google .common .collect .ImmutableSet ;
1920import com .google .gcloud .BaseServiceException ;
2021import com .google .gcloud .RetryHelper .RetryHelperException ;
2122import com .google .gcloud .RetryHelper .RetryInterruptedException ;
2223
2324import java .io .IOException ;
25+ import java .util .Set ;
2426
2527/**
2628 * DNS service exception.
2729 */
2830public 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