Skip to content

Commit 98dfa55

Browse files
authored
map already exists grpc status (#693)
1 parent 049a3d6 commit 98dfa55

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

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

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

18+
import com.uber.cadence.*;
1819
import com.uber.cadence.AccessDeniedError;
1920
import com.uber.cadence.EntityNotExistsError;
2021
import com.uber.cadence.InternalServiceError;
21-
import com.uber.cadence.WorkflowExecutionAlreadyCompletedError;
2222
import io.grpc.Metadata;
2323
import io.grpc.StatusRuntimeException;
2424
import org.apache.thrift.TException;
@@ -32,15 +32,32 @@ public static TException Error(StatusRuntimeException ex) {
3232
return new AccessDeniedError(ex.getMessage());
3333
case INTERNAL:
3434
return new InternalServiceError(ex.getMessage());
35-
case NOT_FOUND: {
36-
switch (details) {
37-
case "EntityNotExistsError":
38-
// TODO add cluster info
39-
return new EntityNotExistsError(ex.getMessage());
40-
case "WorkflowExecutionAlreadyCompletedError":
41-
return new WorkflowExecutionAlreadyCompletedError(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());
43+
}
44+
}
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+
}
59+
}
4260
}
43-
}
4461
default:
4562
// If error does not match anything, return raw grpc status error
4663
// There are some code that casts error to grpc status to check for deadline exceeded status

0 commit comments

Comments
 (0)