From ea388af2686b50c82b14b0cefe45361ac97c7c60 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sun, 7 Aug 2022 01:14:43 +0200 Subject: [PATCH] catch recipient errors --- .../Model/d3linkmobility_ordermanager_sender.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Application/Model/d3linkmobility_ordermanager_sender.php b/src/Application/Model/d3linkmobility_ordermanager_sender.php index 85a7e07..036857b 100644 --- a/src/Application/Model/d3linkmobility_ordermanager_sender.php +++ b/src/Application/Model/d3linkmobility_ordermanager_sender.php @@ -19,6 +19,7 @@ use D3\Linkmobility4Ordermanager\Application\Model\Exceptions\emptyMesageExcepti use D3\Linkmobility4OXID\Application\Model\Exceptions\noRecipientFoundException; use D3\Linkmobility4OXID\Application\Model\MessageTypes\Sms; use D3\Linkmobility4OXID\Application\Model\OrderRecipients; +use D3\LinkmobilityClient\Exceptions\RecipientException; use D3\LinkmobilityClient\ValueObject\Recipient; use D3\ModCfg\Application\Model\d3str; use D3\ModCfg\Application\Model\Exception\d3ParameterNotFoundException; @@ -217,13 +218,19 @@ die(); { $recipients = []; if ((bool) $this->getManager()->getValue('blLinkMobilityMessageToCustomer')) { - $recipients[] = (oxNew(OrderRecipients::class, $this->getItem()))->getSmsRecipient(); + try { + $recipients[] = (oxNew(OrderRecipients::class, $this->getItem()))->getSmsRecipient(); + } catch (noRecipientFoundException $e) {} } if ((bool) $this->getManager()->getValue('blLinkMobilityMessageToCustom') && strlen(trim($this->getManager()->getValue('sLinkMobilityMessageToCustomAddress'))) ) { foreach ($this->extractCustomAddresses() as $phoneNumber => $countryId) { - $recipients[] = oxNew(Recipient::class, $phoneNumber, $countryId); + try { + $recipients[] = oxNew(Recipient::class, $phoneNumber, $countryId); + } catch (RecipientException $e) { + Registry::getLogger()->info($e->getMessage(), [$phoneNumber, $countryId]); + } } }