3 declare(strict_types=1);
14 use GuzzleHttp\Exception\ClientException;
15 use GuzzleHttp\Exception\ServerException;
16 use GuzzleHttp\Psr7\Response;
17 use Psr\Http\Message\ResponseInterface;
24 ?ResponseInterface $response,
27 if (is_null($response)) {
28 $message =
'Error completing request: ' . $e->getMessage();
32 $message =
'Server error response [url] ' . (string)$request->getUri()
33 .
' [status code] ' . (string)$response->getStatusCode()
34 .
' [reason phrase] ' . $response->getReasonPhrase();
36 switch ($response->getStatusCode()) {
47 return new ApiServerException($message, $result, $request, $response, $e, []);
53 ?ResponseInterface $response,
56 if (is_null($response)) {
57 $message =
'Error completing request: ' . $e->getMessage();
61 $message =
'Client error response [url] ' . (string)$request->getUri()
62 .
' [status code] ' . (string)$response->getStatusCode()
63 .
' [reason phrase] ' . $response->getReasonPhrase();
65 switch ($response->getStatusCode()) {
78 return new ApiClientException($message, $result, $request, $response, $e, []);