Update error message in SendEmailAction

[MAILPOET-6174]
This commit is contained in:
Jan Lysý
2024-08-19 18:29:18 +02:00
committed by Jan Jakeš
parent 0761998eba
commit ecf0e1d2db

View File

@@ -295,7 +295,11 @@ class SendEmailAction implements Action {
]);
if (!$subscriberSegment) {
throw InvalidStateException::create()->withMessage(sprintf("Subscriber ID '%s' is not subscribed to segment ID '%s'.", $subscriberId, $segmentId));
$segment = $this->segmentsRepository->findOneById($segmentId);
if (!$segment) { // This state should not happen because it is checked in the validation.
throw InvalidStateException::create()->withMessage("Cannot send the email because the list was not found.");
}
throw InvalidStateException::create()->withMessage(sprintf("Cannot send the email because the subscriber is not subscribed to the '%s' list.", $segment->getName()));
}
$subscriber = $subscriberSegment->getSubscriber();