package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Spatie\FlareClient\Http\Exceptions;
use Exception;
use Spatie\FlareClient\Http\Response;
class BadResponseCode extends Exception
{
public Response $response;
/**
* @var array<int, mixed>
*/
public array $errors = [];
public static function createForResponse(Response $response): self
{
$exception = new self(static::getMessageForResponse($response));
$exception->response = $response;
$bodyErrors = isset($response->getBody()['errors']) ? $response->getBody()['errors'] : [];
$exception->errors = $bodyErrors;
return $exception;
}
public static function getMessageForResponse(Response $response): string
{
return "Response code {$response->getHttpResponseCode()} returned";
}
}