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 (404 , null ),
35
+ new Error (409 , null ),
36
+ new Error (500 , null ),
37
+ new Error (502 , null ),
38
+ new Error (503 , null ));
30
39
private static final long serialVersionUID = 490302380416260252L ;
31
40
32
41
public DnsException (IOException exception ) {
33
42
super (exception , true );
34
43
}
35
44
36
- public DnsException (int code , String message ) {
45
+ private DnsException (int code , String message ) {
37
46
super (code , message , null , true );
38
47
}
39
48
49
+ @ Override
50
+ protected Set <Error > retryableErrors () {
51
+ return RETRYABLE_ERRORS ;
52
+ }
53
+
40
54
/**
41
55
* Translate RetryHelperException to the DnsException that caused the error. This method will
42
56
* always throw an exception.
@@ -48,6 +62,4 @@ static DnsException translateAndThrow(RetryHelperException ex) {
48
62
BaseServiceException .translateAndPropagateIfPossible (ex );
49
63
throw new DnsException (UNKNOWN_CODE , ex .getMessage ());
50
64
}
51
-
52
- //TODO(mderka) Add translation and retry functionality. Created issue #593.
53
65
}
0 commit comments