Throw InvalidStateException when workflow is not found

[MAILPOET-4533]
This commit is contained in:
David Remer
2022-09-14 14:19:18 +03:00
committed by Jan Jakeš
parent a07052c834
commit 339cba3c42

View File

@ -3,6 +3,7 @@
namespace MailPoet\Automation\Engine\Builder;
use MailPoet\Automation\Engine\Data\Workflow;
use MailPoet\Automation\Engine\Exceptions\InvalidStateException;
use MailPoet\Automation\Engine\Storage\WorkflowStorage;
use MailPoet\Automation\Engine\Storage\WorkflowTemplateStorage;
use MailPoet\UnexpectedValueException;
@ -32,7 +33,7 @@ class CreateWorkflowFromTemplateController {
$workflowId = $this->storage->createWorkflow($template->getWorkflow());
$workflow = $this->storage->getWorkflow($workflowId);
if (!$workflow) {
throw UnexpectedValueException::create()->withMessage('Workflow not found.');
throw new InvalidStateException('Workflow not found.');
}
return $workflow;
}