16
16
17
17
package com .google .gcloud .dns ;
18
18
19
+ import com .google .common .collect .ImmutableSet ;
19
20
import com .google .gcloud .BaseServiceException ;
20
21
import com .google .gcloud .RetryHelper .RetryHelperException ;
21
22
import com .google .gcloud .RetryHelper .RetryInterruptedException ;
22
23
23
24
import java .io .IOException ;
25
+ import java .util .Set ;
24
26
25
27
/**
26
28
* DNS service exception.
27
29
*/
28
30
public class DnsException extends BaseServiceException {
29
31
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 ));
30
37
private static final long serialVersionUID = 490302380416260252L ;
31
38
32
39
public DnsException (IOException exception ) {
33
40
super (exception , true );
34
41
}
35
42
36
- public DnsException (int code , String message ) {
43
+ private DnsException (int code , String message ) {
37
44
super (code , message , null , true );
38
45
}
39
46
47
+ @ Override
48
+ protected Set <Error > retryableErrors () {
49
+ return RETRYABLE_ERRORS ;
50
+ }
51
+
40
52
/**
41
53
* Translate RetryHelperException to the DnsException that caused the error. This method will
42
54
* always throw an exception.
@@ -48,6 +60,4 @@ static DnsException translateAndThrow(RetryHelperException ex) {
48
60
BaseServiceException .translateAndPropagateIfPossible (ex );
49
61
throw new DnsException (UNKNOWN_CODE , ex .getMessage ());
50
62
}
51
-
52
- //TODO(mderka) Add translation and retry functionality. Created issue #593.
53
63
}
0 commit comments