From ecf0e1d2db2c827ace7bea5e22e6d58afc7592be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Mon, 19 Aug 2024 18:29:18 +0200 Subject: [PATCH] Update error message in SendEmailAction [MAILPOET-6174] --- .../Integrations/MailPoet/Actions/SendEmailAction.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php b/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php index 8d4d2445c5..a6a0320cda 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php @@ -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();