Skip to content

Commit ef45d74

Browse files
Explicit catching of ExecuteMultiOperation exception cause
1 parent c693a65 commit ef45d74

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,24 @@ private static void runWorkflowWithUpdateWithStart(WorkflowClient client) {
7676
+ result.getTransactionId()
7777
+ ")");
7878
} catch (Exception e) {
79-
System.err.println("Transaction initialization failed: " + e.getMessage());
80-
System.err.println("Cause: " + e.getCause());
79+
if (e.getCause() instanceof io.grpc.StatusRuntimeException) {
80+
io.grpc.StatusRuntimeException sre = (io.grpc.StatusRuntimeException) e.getCause();
81+
82+
System.err.println("Workflow failed with StatusRuntimeException: " + sre.getMessage());
83+
System.err.println("Cause: " + e.getCause());
84+
85+
if (sre.getStatus().getCode() == io.grpc.Status.Code.PERMISSION_DENIED
86+
&& sre.getMessage()
87+
.contains("ExecuteMultiOperation API is disabled on this namespace")) {
88+
89+
// Inform the user that UpdateWithStart requires the ExecuteMultiOperation API to be enabled
90+
System.err.println(
91+
"UpdateWithStart requires the ExecuteMultiOperation API to be enabled on this namespace.");
92+
}
93+
} else {
94+
System.err.println("Transaction initialization failed: " + e.getMessage());
95+
System.err.println("Cause: " + e.getCause());
96+
}
8197
}
8298
}
8399

0 commit comments

Comments
 (0)