We want to process errors for individual subscribers. Subscriber errors were inlined into error message string. This commit changes this so that we are now able to get subscriber errors as a data which are easy to process further. [MAILPOET-1154]
23 lines
735 B
PHP
23 lines
735 B
PHP
<?php
|
|
namespace MailPoet\Mailer\Methods\ErrorMappers;
|
|
|
|
use MailPoet\Mailer\MailerError;
|
|
use MailPoet\Mailer\Mailer;
|
|
use MailPoet\Mailer\SubscriberError;
|
|
|
|
class SendGridMapper {
|
|
use ConnectionErrorMapperTrait;
|
|
|
|
function getErrorFromResponse($response, $subscriber, $extra_params) {
|
|
$response = (!empty($response['errors'][0])) ?
|
|
$response['errors'][0] :
|
|
sprintf(__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_SENDGRID);
|
|
|
|
$subscriber_errors = [];
|
|
if(empty($extra_params['test_email'])) {
|
|
$subscriber_errors[] = new SubscriberError($subscriber, null);
|
|
}
|
|
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, $response, null, $subscriber_errors);
|
|
}
|
|
}
|