PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / vendor / vendor-prefixed / stellarwp / licensing-api-client / src / Exceptions / ApiResponseException.php

ApiResponseException.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/vendor-prefixed/stellarwp/licensing-api-client/src/Exceptions/ApiResponseException.php

73 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace Give\Vendors\LiquidWeb\LicensingApiClient\Exceptions;
4
5 use Give\Vendors\LiquidWeb\LicensingApiClient\Exceptions\Contracts\ApiErrorExceptionInterface;
6 use Give\Vendors\Psr\Http\Message\ResponseInterface;
7 use RuntimeException;
8
9 /**
10 * Base exception for HTTP error responses returned by the licensing API.
11 */
12 class ApiResponseException extends RuntimeException implements ApiErrorExceptionInterface
13 {
14 private ResponseInterface $response;
15
16 private int $statusCode;
17
18 private string $errorCode;
19
20 /**
21 * @var array<array-key, mixed>|null
22 */
23 private ?array $errorPayload;
24
25 /**
26 * @param array<array-key, mixed>|null $errorPayload
27 */
28 public function __construct(
29 string $message,
30 ResponseInterface $response,
31 int $statusCode,
32 string $errorCode,
33 ?array $errorPayload = null
34 ) {
35 parent::__construct($message, $statusCode);
36
37 $this->response = $response;
38 $this->statusCode = $statusCode;
39 $this->errorCode = $errorCode;
40 $this->errorPayload = $errorPayload;
41 }
42
43 /**
44 * Returns the raw PSR-7 response that triggered the exception.
45 */
46 public function getResponse(): ResponseInterface {
47 return $this->response;
48 }
49
50 /**
51 * Returns the HTTP status code from the failed response.
52 */
53 public function statusCode(): int {
54 return $this->statusCode;
55 }
56
57 /**
58 * Returns the normalized API error code.
59 */
60 public function errorCode(): string {
61 return $this->errorCode;
62 }
63
64 /**
65 * Returns the decoded error payload when the response body matched a known JSON error shape.
66 *
67 * @return array<array-key, mixed>|null
68 */
69 public function errorPayload(): ?array {
70 return $this->errorPayload;
71 }
72 }
73