Add subscriber errors passing via MailerError object
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]
This commit is contained in:
@ -3,6 +3,7 @@ namespace MailPoet\Mailer\Methods\ErrorMappers;
|
||||
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\SubscriberError;
|
||||
|
||||
class SendGridMapper {
|
||||
use ConnectionErrorMapperTrait;
|
||||
@ -11,9 +12,11 @@ class SendGridMapper {
|
||||
$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'])) {
|
||||
$response .= sprintf(' %s: %s', __('Unprocessed subscriber', 'mailpoet'), $subscriber);
|
||||
$subscriber_errors[] = new SubscriberError($subscriber, null);
|
||||
}
|
||||
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, $response);
|
||||
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, $response, null, $subscriber_errors);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user