109
109
import io .grpc .StatusRuntimeException ;
110
110
import java .util .UUID ;
111
111
import java .util .concurrent .CompletableFuture ;
112
+ import java .util .concurrent .ExecutionException ;
112
113
import java .util .concurrent .ForkJoinPool ;
113
114
import java .util .concurrent .TimeUnit ;
114
115
import org .apache .thrift .TException ;
@@ -203,7 +204,7 @@ public RestartWorkflowExecutionResponse RestartWorkflowExecution(
203
204
RestartWorkflowExecutionRequest restartRequest )
204
205
throws BadRequestError , ServiceBusyError , DomainNotActiveError , LimitExceededError ,
205
206
EntityNotExistsError , ClientVersionNotSupportedError , TException {
206
- throw new IllegalArgumentException ("unimplemented" );
207
+ throw new UnsupportedOperationException ("unimplemented" );
207
208
}
208
209
209
210
@ Override
@@ -851,7 +852,7 @@ public void DeprecateDomain(
851
852
public void RestartWorkflowExecution (
852
853
RestartWorkflowExecutionRequest restartRequest , AsyncMethodCallback resultHandler )
853
854
throws TException {
854
- throw new IllegalArgumentException ("unimplemented" );
855
+ throw new UnsupportedOperationException ("unimplemented" );
855
856
}
856
857
857
858
@ Override
@@ -880,7 +881,7 @@ public void StartWorkflowExecutionAsync(
880
881
resultHandler .onComplete (
881
882
ResponseMapper .startWorkflowExecutionAsyncResponse (response ));
882
883
} catch (Exception e ) {
883
- resultHandler . onError ( e );
884
+ handleAsyncException ( resultHandler , e );
884
885
}
885
886
},
886
887
ForkJoinPool .commonPool ());
@@ -1003,7 +1004,7 @@ public void SignalWorkflowExecution(
1003
1004
com .uber .cadence .api .v1 .SignalWorkflowExecutionResponse response = resultFuture .get ();
1004
1005
resultHandler .onComplete (null );
1005
1006
} catch (Exception e ) {
1006
- resultHandler . onError ( e );
1007
+ handleAsyncException ( resultHandler , e );
1007
1008
}
1008
1009
},
1009
1010
ForkJoinPool .commonPool ());
@@ -1025,7 +1026,7 @@ public void SignalWithStartWorkflowExecutionAsync(
1025
1026
SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest ,
1026
1027
AsyncMethodCallback resultHandler )
1027
1028
throws TException {
1028
- throw new IllegalArgumentException ("unimplemented" );
1029
+ throw new UnsupportedOperationException ("unimplemented" );
1029
1030
}
1030
1031
1031
1032
@ Override
@@ -1199,7 +1200,7 @@ public void StartWorkflowExecutionWithTimeout(
1199
1200
com .uber .cadence .api .v1 .StartWorkflowExecutionResponse response = resultFuture .get ();
1200
1201
resultHandler .onComplete (ResponseMapper .startWorkflowExecutionResponse (response ));
1201
1202
} catch (Exception e ) {
1202
- resultHandler . onError ( e );
1203
+ handleAsyncException ( resultHandler , e );
1203
1204
}
1204
1205
},
1205
1206
ForkJoinPool .commonPool ());
@@ -1230,7 +1231,7 @@ public void StartWorkflowExecutionAsyncWithTimeout(
1230
1231
resultHandler .onComplete (
1231
1232
ResponseMapper .startWorkflowExecutionAsyncResponse (response ));
1232
1233
} catch (Exception e ) {
1233
- resultHandler . onError ( e );
1234
+ handleAsyncException ( resultHandler , e );
1234
1235
}
1235
1236
},
1236
1237
ForkJoinPool .commonPool ());
@@ -1276,7 +1277,7 @@ public void GetWorkflowExecutionHistoryWithTimeout(
1276
1277
resultHandler .onComplete (
1277
1278
ResponseMapper .getWorkflowExecutionHistoryResponse (response ));
1278
1279
} catch (Exception e ) {
1279
- resultHandler . onError ( e );
1280
+ handleAsyncException ( resultHandler , e );
1280
1281
}
1281
1282
},
1282
1283
ForkJoinPool .commonPool ());
@@ -1293,4 +1294,13 @@ public void SignalWorkflowExecutionWithTimeout(
1293
1294
throws TException {
1294
1295
throw new UnsupportedOperationException ("not implemented" );
1295
1296
}
1297
+
1298
+ private void handleAsyncException (AsyncMethodCallback callback , Exception exception ) {
1299
+ if (exception instanceof ExecutionException
1300
+ && exception .getCause () instanceof StatusRuntimeException ) {
1301
+ callback .onError (ErrorMapper .Error (((StatusRuntimeException ) exception .getCause ())));
1302
+ } else {
1303
+ callback .onError (exception );
1304
+ }
1305
+ }
1296
1306
}
0 commit comments