API.php
6 months ago
AbstractListingEndpoint.php
3 weeks ago
ApiException.php
2 months ago
Endpoint.php
3 months ago
EndpointContainer.php
3 years ago
ErrorResponse.php
3 years ago
Exception.php
3 years ago
ListingRequestValidationTrait.php
1 month ago
Request.php
3 years ago
Response.php
1 year ago
index.php
3 years ago
ApiException.php
49 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\API\REST; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use Exception as PhpException; |
| 9 | use Throwable; |
| 10 | |
| 11 | class ApiException extends PhpException implements Exception { |
| 12 | /** @var int */ |
| 13 | private $statusCode; |
| 14 | |
| 15 | /** @var string */ |
| 16 | private $errorCode; |
| 17 | |
| 18 | /** @var array<string, string> */ |
| 19 | private $errors; |
| 20 | |
| 21 | /** |
| 22 | * @param array<string, string> $errors |
| 23 | */ |
| 24 | public function __construct( |
| 25 | string $message, |
| 26 | int $statusCode = 400, |
| 27 | string $errorCode = 'mailpoet_rest_api_error', |
| 28 | array $errors = [], |
| 29 | ?Throwable $previous = null |
| 30 | ) { |
| 31 | parent::__construct($message, 0, $previous); |
| 32 | $this->statusCode = $statusCode; |
| 33 | $this->errorCode = $errorCode; |
| 34 | $this->errors = $errors; |
| 35 | } |
| 36 | |
| 37 | public function getStatusCode(): int { |
| 38 | return $this->statusCode; |
| 39 | } |
| 40 | |
| 41 | public function getErrorCode(): string { |
| 42 | return $this->errorCode; |
| 43 | } |
| 44 | |
| 45 | public function getErrors(): array { |
| 46 | return $this->errors; |
| 47 | } |
| 48 | } |
| 49 |