koel/app/Exceptions/FailedToActivateLicenseException.php

23 lines
528 B
PHP
Raw Normal View History

2024-01-05 16:42:50 +00:00
<?php
namespace App\Exceptions;
use Exception;
use GuzzleHttp\Exception\ClientException;
2024-01-05 16:42:50 +00:00
use Throwable;
class FailedToActivateLicenseException extends Exception
{
public static function fromThrowable(Throwable $e): self
2024-01-05 16:42:50 +00:00
{
return new static($e->getMessage(), $e->getCode(), $e);
}
public static function fromClientException(ClientException $e): self
{
$response = $e->getResponse();
return new static(json_decode($response->getBody())->error, $response->getStatusCode());
}
2024-01-05 16:42:50 +00:00
}