zingimmick/laravel-sms

View on GitHub
src/Exceptions/CouldNotSendNotification.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types=1);

namespace Zing\LaravelSms\Exceptions;

use Throwable;

class CouldNotSendNotification extends Exception
{
    /**
     * @var mixed[]
     */
    public $raw = [];

    /**
     * @param mixed[] $raw
     */
    public function __construct(string $message = '', int $code = 0, array $raw = [])
    {
        parent::__construct($message, $code);

        $this->raw = $raw;
    }

    public static function captureExceptionInDriver(Throwable $exception): self
    {
        if ($exception instanceof self) {
            return $exception;
        }

        return new self($exception->getMessage(), $exception->getCode());
    }
}