-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw WorkflowUpdateResultException when an update result was not pro…
…vided
- Loading branch information
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of Temporal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Exception\Client; | ||
|
||
use Temporal\Client\Update\LifecycleStage; | ||
use Temporal\Workflow\WorkflowExecution; | ||
|
||
/** | ||
* Indicates that a Workflow Update has no result yet. | ||
*/ | ||
final class WorkflowUpdateResultException extends WorkflowException | ||
{ | ||
public function __construct( | ||
private readonly ?LifecycleStage $stage, | ||
WorkflowExecution $execution, | ||
string $workflowType, | ||
private readonly string $updateId, | ||
private readonly string $updateName, | ||
) { | ||
$message = match ($stage) { | ||
LifecycleStage::StageAdmitted => \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; | ||
} | ||
} |