32 lines
685 B
PHP
32 lines
685 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Mailjet\Response;
|
|
use RuntimeException;
|
|
|
|
class MailjetException extends RuntimeException
|
|
{
|
|
/**
|
|
* Error message returned by the Mailjet API
|
|
*
|
|
* @var string
|
|
*/
|
|
public string $returnedMessage;
|
|
|
|
/**
|
|
* Create a new Mailjet exception
|
|
*
|
|
* @param \Mailjet\Response $response
|
|
* @param string $message
|
|
*/
|
|
public function __construct(Response $response, string $message)
|
|
{
|
|
$this->returnedMessage = $response->getBody()['ErrorMessage'] ?? $response->getReasonPhrase();
|
|
|
|
parent::__construct(
|
|
$message,
|
|
$response->getStatus()
|
|
);
|
|
}
|
|
}
|