koel/app/Exceptions/FailedToActivateLicenseException.php

25 lines
597 B
PHP
Raw Normal View History

2024-01-05 16:42:50 +00:00
<?php
namespace App\Exceptions;
use Exception;
use Saloon\Exceptions\Request\RequestException;
2024-01-05 16:42:50 +00:00
use Throwable;
final class FailedToActivateLicenseException extends Exception
2024-01-05 16:42:50 +00:00
{
public static function fromThrowable(Throwable $e): self
2024-01-05 16:42:50 +00:00
{
return new self($e->getMessage(), $e->getCode(), $e);
2024-01-05 16:42:50 +00:00
}
public static function fromRequestException(RequestException $e): self
{
try {
return new self(object_get($e->getResponse()->object(), 'error'), $e->getStatus());
} catch (Throwable) {
return self::fromThrowable($e);
}
}
2024-01-05 16:42:50 +00:00
}