ldc-crm/app/Exceptions/MailjetException.php
2026-10-08 10:06:20 +02:00

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()
);
}
}