diff --git a/src/Client/Update/UpdateHandle.php b/src/Client/Update/UpdateHandle.php index 4183e531..395aa7db 100644 --- a/src/Client/Update/UpdateHandle.php +++ b/src/Client/Update/UpdateHandle.php @@ -13,6 +13,7 @@ use Temporal\Exception\Client\CanceledException; use Temporal\Exception\Client\TimeoutException; use Temporal\Exception\Client\WorkflowUpdateException; +use Temporal\Exception\Client\WorkflowUpdateResultException; use Temporal\Exception\Client\WorkflowUpdateRPCTimeoutOrCanceledException; use Temporal\Exception\Failure\FailureConverter; use Temporal\Workflow\WorkflowExecution; @@ -127,7 +128,13 @@ private function fetchResult(int|float|null $timeout = null): void // Workflow Uprate accepted $result = $response->getOutcome(); - \assert($result !== null); + $result === null and throw new WorkflowUpdateResultException( + LifecycleStage::tryFrom($response->getStage()), + execution: $this->getExecution(), + workflowType: $this->workflowType ?? '', + updateId: $this->getId(), + updateName: $this->updateName, + ); // Accepted with result if ($result->getSuccess() !== null) { diff --git a/src/Exception/Client/WorkflowUpdateResultException.php b/src/Exception/Client/WorkflowUpdateResultException.php new file mode 100644 index 00000000..ad4ca413 --- /dev/null +++ b/src/Exception/Client/WorkflowUpdateResultException.php @@ -0,0 +1,55 @@ + \sprintf( + "Update `%s` has not yet been accepted or rejected by the Workflow `%s`.", + $updateName, + $workflowType, + ), + default => \sprintf("Update `%s` has no result.", $updateName), + }; + + parent::__construct($message, $execution, $workflowType); + } + + public function getUpdateId(): string + { + return $this->updateId; + } + + public function getUpdateName(): string + { + return $this->updateName; + } + + public function getStage(): LifecycleStage + { + return $this->stage ?? LifecycleStage::StageUnspecified; + } +}