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