@@ -221,6 +221,9 @@ private void convertAndThrowStatusException(StatusRuntimeException e)
221
221
throws BadRequestError , WorkflowExecutionAlreadyStartedError , ServiceBusyError ,
222
222
DomainNotActiveError , LimitExceededError , EntityNotExistsError ,
223
223
ClientVersionNotSupportedError {
224
+ if (e .getCause () != null ) {
225
+ e .getMessage ();
226
+ }
224
227
// TODO handle all errors depending on status
225
228
switch (e .getStatus ().getCode ()) {
226
229
case ALREADY_EXISTS : {
@@ -451,8 +454,7 @@ public void RespondActivityTaskCanceledByID(
451
454
}
452
455
453
456
@ Override
454
- public void RequestCancelWorkflowExecution (RequestCancelWorkflowExecutionRequest
455
- cancelRequest )
457
+ public void RequestCancelWorkflowExecution (RequestCancelWorkflowExecutionRequest cancelRequest )
456
458
throws BadRequestError , EntityNotExistsError , CancellationAlreadyRequestedError ,
457
459
ServiceBusyError , DomainNotActiveError , LimitExceededError ,
458
460
ClientVersionNotSupportedError , WorkflowExecutionAlreadyCompletedError , TException {
@@ -490,37 +492,52 @@ public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
490
492
throws BadRequestError , EntityNotExistsError , ServiceBusyError , DomainNotActiveError ,
491
493
LimitExceededError , WorkflowExecutionAlreadyStartedError , ClientVersionNotSupportedError ,
492
494
TException {
493
- signalWithStartRequest .setRequestId (UUID .randomUUID ().toString ());
494
- com .uber .cadence .api .v1 .SignalWithStartWorkflowExecutionResponse response =
495
- grpcServiceStubs
496
- .workflowBlockingStub ()
497
- .signalWithStartWorkflowExecution (
498
- RequestMapper .signalWithStartWorkflowExecutionRequest (signalWithStartRequest ));
499
- return ResponseMapper .signalWithStartWorkflowExecutionResponse (response );
495
+ try {
496
+ signalWithStartRequest .setRequestId (UUID .randomUUID ().toString ());
497
+ com .uber .cadence .api .v1 .SignalWithStartWorkflowExecutionResponse response =
498
+ grpcServiceStubs
499
+ .workflowBlockingStub ()
500
+ .signalWithStartWorkflowExecution (
501
+ RequestMapper .signalWithStartWorkflowExecutionRequest (signalWithStartRequest ));
502
+ return ResponseMapper .signalWithStartWorkflowExecutionResponse (response );
503
+ } catch (StatusRuntimeException e ) {
504
+ convertAndThrowStatusException (e );
505
+ throw e ;
506
+ }
500
507
}
501
508
502
509
@ Override
503
510
public ResetWorkflowExecutionResponse ResetWorkflowExecution (
504
511
ResetWorkflowExecutionRequest resetRequest )
505
512
throws BadRequestError , EntityNotExistsError , ServiceBusyError , DomainNotActiveError ,
506
513
LimitExceededError , ClientVersionNotSupportedError , TException {
507
- resetRequest .setRequestId (UUID .randomUUID ().toString ());
508
- com .uber .cadence .api .v1 .ResetWorkflowExecutionResponse response =
509
- grpcServiceStubs
510
- .workflowBlockingStub ()
511
- .resetWorkflowExecution (RequestMapper .resetWorkflowExecutionRequest (resetRequest ));
512
- return ResponseMapper .resetWorkflowExecutionResponse (response );
514
+ try {
515
+ resetRequest .setRequestId (UUID .randomUUID ().toString ());
516
+ com .uber .cadence .api .v1 .ResetWorkflowExecutionResponse response =
517
+ grpcServiceStubs
518
+ .workflowBlockingStub ()
519
+ .resetWorkflowExecution (RequestMapper .resetWorkflowExecutionRequest (resetRequest ));
520
+ return ResponseMapper .resetWorkflowExecutionResponse (response );
521
+ } catch (StatusRuntimeException e ) {
522
+ convertAndThrowStatusException (e );
523
+ throw e ;
524
+ }
513
525
}
514
526
515
527
@ Override
516
528
public void TerminateWorkflowExecution (TerminateWorkflowExecutionRequest terminateRequest )
517
529
throws BadRequestError , EntityNotExistsError , ServiceBusyError , DomainNotActiveError ,
518
530
LimitExceededError , ClientVersionNotSupportedError ,
519
531
WorkflowExecutionAlreadyCompletedError , TException {
520
- grpcServiceStubs
521
- .workflowBlockingStub ()
522
- .terminateWorkflowExecution (
523
- RequestMapper .terminateWorkflowExecutionRequest (terminateRequest ));
532
+ try {
533
+ grpcServiceStubs
534
+ .workflowBlockingStub ()
535
+ .terminateWorkflowExecution (
536
+ RequestMapper .terminateWorkflowExecutionRequest (terminateRequest ));
537
+ } catch (StatusRuntimeException e ) {
538
+ convertAndThrowStatusException (e );
539
+ throw e ;
540
+ }
524
541
}
525
542
526
543
@ Override
@@ -594,8 +611,7 @@ public CountWorkflowExecutionsResponse CountWorkflowExecutions(
594
611
com .uber .cadence .api .v1 .CountWorkflowExecutionsResponse response =
595
612
grpcServiceStubs
596
613
.visibilityBlockingStub ()
597
- .countWorkflowExecutions (
598
- RequestMapper .countWorkflowExecutionsRequest (countRequest ));
614
+ .countWorkflowExecutions (RequestMapper .countWorkflowExecutionsRequest (countRequest ));
599
615
return ResponseMapper .countWorkflowExecutionsResponse (response );
600
616
}
601
617
@@ -615,13 +631,11 @@ public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeR
615
631
DomainNotActiveError , ClientVersionNotSupportedError , TException {
616
632
grpcServiceStubs
617
633
.workerBlockingStub ()
618
- .respondQueryTaskCompleted (
619
- RequestMapper .respondQueryTaskCompletedRequest (completeRequest ));
634
+ .respondQueryTaskCompleted (RequestMapper .respondQueryTaskCompletedRequest (completeRequest ));
620
635
}
621
636
622
637
@ Override
623
- public ResetStickyTaskListResponse ResetStickyTaskList (ResetStickyTaskListRequest
624
- resetRequest )
638
+ public ResetStickyTaskListResponse ResetStickyTaskList (ResetStickyTaskListRequest resetRequest )
625
639
throws BadRequestError , EntityNotExistsError , LimitExceededError , ServiceBusyError ,
626
640
DomainNotActiveError , ClientVersionNotSupportedError ,
627
641
WorkflowExecutionAlreadyCompletedError , TException {
@@ -705,15 +719,13 @@ public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest request)
705
719
706
720
@ Override
707
721
public void RegisterDomain (
708
- RegisterDomainRequest registerRequest , AsyncMethodCallback resultHandler ) throws
709
- TException {
722
+ RegisterDomainRequest registerRequest , AsyncMethodCallback resultHandler ) throws TException {
710
723
throw new UnsupportedOperationException ("not implemented" );
711
724
}
712
725
713
726
@ Override
714
727
public void DescribeDomain (
715
- DescribeDomainRequest describeRequest , AsyncMethodCallback resultHandler ) throws
716
- TException {
728
+ DescribeDomainRequest describeRequest , AsyncMethodCallback resultHandler ) throws TException {
717
729
throw new UnsupportedOperationException ("not implemented" );
718
730
}
719
731
@@ -752,8 +764,7 @@ public void GetWorkflowExecutionHistory(
752
764
753
765
@ Override
754
766
public void PollForDecisionTask (
755
- PollForDecisionTaskRequest pollRequest , AsyncMethodCallback resultHandler ) throws
756
- TException {
767
+ PollForDecisionTaskRequest pollRequest , AsyncMethodCallback resultHandler ) throws TException {
757
768
throw new UnsupportedOperationException ("not implemented" );
758
769
}
759
770
@@ -773,8 +784,7 @@ public void RespondDecisionTaskFailed(
773
784
774
785
@ Override
775
786
public void PollForActivityTask (
776
- PollForActivityTaskRequest pollRequest , AsyncMethodCallback resultHandler ) throws
777
- TException {
787
+ PollForActivityTaskRequest pollRequest , AsyncMethodCallback resultHandler ) throws TException {
778
788
throw new UnsupportedOperationException ("not implemented" );
779
789
}
780
790
@@ -849,13 +859,11 @@ public void SignalWorkflowExecution(
849
859
ListenableFuture <com .uber .cadence .api .v1 .SignalWorkflowExecutionResponse > resultFuture =
850
860
grpcServiceStubs
851
861
.workflowFutureStub ()
852
- .signalWorkflowExecution (
853
- RequestMapper .signalWorkflowExecutionRequest (signalRequest ));
862
+ .signalWorkflowExecution (RequestMapper .signalWorkflowExecutionRequest (signalRequest ));
854
863
resultFuture .addListener (
855
864
() -> {
856
865
try {
857
- com .uber .cadence .api .v1 .SignalWorkflowExecutionResponse response = resultFuture
858
- .get ();
866
+ com .uber .cadence .api .v1 .SignalWorkflowExecutionResponse response = resultFuture .get ();
859
867
resultHandler .onComplete (null );
860
868
} catch (Exception e ) {
861
869
resultHandler .onError (e );
@@ -948,8 +956,7 @@ public void ResetStickyTaskList(
948
956
}
949
957
950
958
@ Override
951
- public void QueryWorkflow (QueryWorkflowRequest queryRequest , AsyncMethodCallback
952
- resultHandler )
959
+ public void QueryWorkflow (QueryWorkflowRequest queryRequest , AsyncMethodCallback resultHandler )
953
960
throws TException {
954
961
throw new UnsupportedOperationException ("not implemented" );
955
962
}
@@ -962,8 +969,7 @@ public void DescribeWorkflowExecution(
962
969
}
963
970
964
971
@ Override
965
- public void DescribeTaskList (DescribeTaskListRequest request , AsyncMethodCallback
966
- resultHandler )
972
+ public void DescribeTaskList (DescribeTaskListRequest request , AsyncMethodCallback resultHandler )
967
973
throws TException {
968
974
throw new UnsupportedOperationException ("not implemented" );
969
975
}
@@ -981,8 +987,7 @@ public void GetTaskListsByDomain(
981
987
982
988
@ Override
983
989
public void ListTaskListPartitions (
984
- ListTaskListPartitionsRequest request , AsyncMethodCallback resultHandler ) throws
985
- TException {
990
+ ListTaskListPartitionsRequest request , AsyncMethodCallback resultHandler ) throws TException {
986
991
throw new UnsupportedOperationException ("not implemented" );
987
992
}
988
993
@@ -1042,8 +1047,7 @@ public void StartWorkflowExecutionWithTimeout(
1042
1047
resultFuture .addListener (
1043
1048
() -> {
1044
1049
try {
1045
- com .uber .cadence .api .v1 .StartWorkflowExecutionResponse response = resultFuture
1046
- .get ();
1050
+ com .uber .cadence .api .v1 .StartWorkflowExecutionResponse response = resultFuture .get ();
1047
1051
resultHandler .onComplete (ResponseMapper .startWorkflowExecutionResponse (response ));
1048
1052
} catch (Exception e ) {
1049
1053
resultHandler .onError (e );
@@ -1082,8 +1086,7 @@ public void GetWorkflowExecutionHistoryWithTimeout(
1082
1086
try {
1083
1087
com .uber .cadence .api .v1 .GetWorkflowExecutionHistoryResponse response =
1084
1088
resultFuture .get ();
1085
- resultHandler
1086
- .onComplete (ResponseMapper .getWorkflowExecutionHistoryResponse (response ));
1089
+ resultHandler .onComplete (ResponseMapper .getWorkflowExecutionHistoryResponse (response ));
1087
1090
} catch (Exception e ) {
1088
1091
resultHandler .onError (e );
1089
1092
}
0 commit comments