Problem/Motivation
If the Postmark API key is missing or wrong and an attempt is made to send an email, then Postmark generates an exception "PostmarkException" that contains the message
Unauthorized: Missing or incorrect API token in header. Please verify that you used the correct token when you constructed your client.
The entry posted to the DB log has
$this->logger->error('Postmark exception occurred while trying to send email from %from to %to. @code: @message',
[
'%from' => $sender_signature,
'%to' => $params['to'],
'@code' => $e->postmarkApiErrorCode,
'@message' => $e->message,
]
but the value $e->postmarkApiErrorCode is NULL. This causes Html::escape() to throw a TypeError when the dblog view renders the entry
Steps to reproduce
Load an invalid API key and send a test message, then check the DB log.
Proposed resolution
Update the log call to read:
$this->logger->error('Postmark exception occurred while trying to send email from %from to %to. @code: @message',
[
'%from' => $sender_signature,
'%to' => $params['to'],
'@code' => $e->postmarkApiErrorCode ?? '',
'@message' => $e->message ?? '',
]
Issue fork postmark-3594060
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
dkmishra commentedComment #5
i-trokhanenkoComment #7
i-trokhanenko