function sparkpost_sparkpost_mailsend_error in Sparkpost email 7.2
Same name and namespace in other branches
- 7 sparkpost.module \sparkpost_sparkpost_mailsend_error()
Implements hook_sparkpost_mailsend_error().
File
- ./
sparkpost.module, line 253 - Sparkpost integration.
Code
function sparkpost_sparkpost_mailsend_error(SparkpostMessageWrapper $message_wrapper) {
$e = $message_wrapper
->getApiResponseException();
if ($e instanceof \SparkPost\APIResponseException) {
$message_arguments = array(
'%message' => $e
->getMessage(),
'@code' => $e
->getCode(),
'@api_code' => $e
->getAPICode(),
'%api_message' => $e
->getAPIMessage(),
'%api_description' => $e
->getAPIDescription(),
);
// Log error to watchdog.
watchdog('sparkpost', 'Message could not be sent: @code: %message; @api_code: %api_message %api_description', $message_arguments, WATCHDOG_ERROR);
// In addition, if debug is on, dump message_wrapper as well.
if (variable_get('sparkpost_debug', TRUE)) {
$message_arguments = array(
'!message_wrapper' => print_r($message_wrapper, TRUE),
);
watchdog('sparkpost', 'Debug: <pre>!message_wrapper</pre>', $message_arguments, WATCHDOG_DEBUG);
}
}
}