@@ -118,13 +118,14 @@ def start_workflow_execution(
118
118
119
119
client . start_workflow_execution ( request )
120
120
rescue ::GRPC ::AlreadyExists => e
121
- cast_error = e . to_rpc_status &.details &.map do |any_error |
122
- next unless any_error . type_url == 'type.googleapis.com/temporal.api.errordetails.v1.WorkflowExecutionAlreadyStartedFailure'
123
-
124
- any_error . unpack ( Temporal ::Api ::ErrorDetails ::V1 ::WorkflowExecutionAlreadyStartedFailure )
125
- end &.compact &.first
121
+ error_details_from ( e ) . each do |error |
122
+ case error
123
+ when Temporal ::Api ::ErrorDetails ::V1 ::WorkflowExecutionAlreadyStartedFailure
124
+ raise Temporal ::WorkflowExecutionAlreadyStartedFailure . new ( e . details , error . run_id )
125
+ end
126
+ end
126
127
127
- raise Temporal ::WorkflowExecutionAlreadyStartedFailure . new ( e . details , cast_error &. run_id )
128
+ raise Temporal ::ApiError , e . details # unhandled error type
128
129
end
129
130
130
131
SERVER_MAX_GET_WORKFLOW_EXECUTION_HISTORY_POLL = 30
@@ -138,7 +139,7 @@ def get_workflow_execution_history(
138
139
event_type : :all ,
139
140
timeout : nil
140
141
)
141
- if wait_for_new_event
142
+ if wait_for_new_event
142
143
if timeout . nil?
143
144
# This is an internal error. Wrappers should enforce this.
144
145
raise "You must specify a timeout when wait_for_new_event = true."
@@ -366,7 +367,17 @@ def signal_with_start_workflow_execution(
366
367
request . workflow_id_reuse_policy = policy
367
368
end
368
369
370
+
369
371
client . signal_with_start_workflow_execution ( request )
372
+ rescue ::GRPC ::AlreadyExists => e
373
+ error_details_from ( e ) . each do |error |
374
+ case error
375
+ when Temporal ::Api ::ErrorDetails ::V1 ::WorkflowExecutionAlreadyStartedFailure
376
+ raise Temporal ::WorkflowExecutionAlreadyStartedFailure . new ( e . details , error . run_id )
377
+ end
378
+ end
379
+
380
+ raise Temporal ::ApiError , e . details # unhandled error type
370
381
end
371
382
372
383
def reset_workflow_execution ( namespace :, workflow_id :, run_id :, reason :, workflow_task_event_id :)
@@ -488,6 +499,15 @@ def client
488
499
def can_poll?
489
500
@poll
490
501
end
502
+
503
+ def error_details_from ( error )
504
+ error . to_rpc_status &.details &.map do |any_error |
505
+ type = Google ::Protobuf ::DescriptorPool . generated_pool . lookup any_error . type_url . split ( '/' ) . last
506
+ next if type . nil?
507
+
508
+ any_error . unpack type . msgclass
509
+ end &.compact
510
+ end
491
511
end
492
512
end
493
513
end
0 commit comments