Skip to content

Commit 54d886c

Browse files
authored
handle data loss and version-feature check (#694)
1 parent 98dfa55 commit 54d886c

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

src/main/java/com/uber/cadence/internal/compatibility/thrift/ErrorMapper.java

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
*/
1616
package com.uber.cadence.internal.compatibility.thrift;
1717

18-
import com.uber.cadence.*;
1918
import com.uber.cadence.AccessDeniedError;
19+
import com.uber.cadence.CancellationAlreadyRequestedError;
20+
import com.uber.cadence.ClientVersionNotSupportedError;
21+
import com.uber.cadence.DomainAlreadyExistsError;
22+
import com.uber.cadence.DomainNotActiveError;
2023
import com.uber.cadence.EntityNotExistsError;
24+
import com.uber.cadence.FeatureNotEnabledError;
25+
import com.uber.cadence.InternalDataInconsistencyError;
2126
import com.uber.cadence.InternalServiceError;
27+
import com.uber.cadence.WorkflowExecutionAlreadyCompletedError;
28+
import com.uber.cadence.WorkflowExecutionAlreadyStartedError;
2229
import io.grpc.Metadata;
2330
import io.grpc.StatusRuntimeException;
2431
import org.apache.thrift.TException;
@@ -32,30 +39,42 @@ public static TException Error(StatusRuntimeException ex) {
3239
return new AccessDeniedError(ex.getMessage());
3340
case INTERNAL:
3441
return new InternalServiceError(ex.getMessage());
35-
case NOT_FOUND:
36-
{
37-
switch (details) {
38-
case "EntityNotExistsError":
39-
// TODO add cluster info
40-
return new EntityNotExistsError(ex.getMessage());
41-
case "WorkflowExecutionAlreadyCompletedError":
42-
return new WorkflowExecutionAlreadyCompletedError(ex.getMessage());
42+
case NOT_FOUND: {
43+
switch (details) {
44+
case "EntityNotExistsError":
45+
// TODO add cluster info
46+
return new EntityNotExistsError(ex.getMessage());
47+
case "WorkflowExecutionAlreadyCompletedError":
48+
return new WorkflowExecutionAlreadyCompletedError(ex.getMessage());
49+
}
50+
}
51+
case ALREADY_EXISTS: {
52+
switch (details) {
53+
case "CancellationAlreadyRequestedError":
54+
return new CancellationAlreadyRequestedError(ex.getMessage());
55+
case "DomainAlreadyExistsError":
56+
return new DomainAlreadyExistsError(ex.getMessage());
57+
case "WorkflowExecutionAlreadyStartedError": {
58+
// TODO add started wf info
59+
WorkflowExecutionAlreadyStartedError e = new WorkflowExecutionAlreadyStartedError();
60+
e.setMessage(ex.getMessage());
61+
return e;
4362
}
4463
}
45-
case ALREADY_EXISTS:
46-
{
47-
switch (details) {
48-
case "CancellationAlreadyRequestedError":
49-
return new CancellationAlreadyRequestedError(ex.getMessage());
50-
case "DomainAlreadyExistsError":
51-
return new DomainAlreadyExistsError(ex.getMessage());
52-
case "WorkflowExecutionAlreadyStartedError":
53-
{
54-
// TODO add started wf info
55-
WorkflowExecutionAlreadyStartedError e = new WorkflowExecutionAlreadyStartedError();
56-
e.setMessage(ex.getMessage());
57-
return e;
58-
}
64+
}
65+
case DATA_LOSS:
66+
return new InternalDataInconsistencyError(ex.getMessage());
67+
case FAILED_PRECONDITION:
68+
switch (details) {
69+
// TODO add infos
70+
case "ClientVersionNotSupportedError":
71+
return new ClientVersionNotSupportedError();
72+
case "FeatureNotEnabledError":
73+
return new FeatureNotEnabledError();
74+
case "DomainNotActiveError": {
75+
DomainNotActiveError e = new DomainNotActiveError();
76+
e.setMessage(ex.getMessage());
77+
return e;
5978
}
6079
}
6180
default:

0 commit comments

Comments
 (0)