give
/
src
/
API
/
REST
/
V3
/
Routes
/
Subscriptions
/
Exceptions
/
SubscriptionValidationException.php
SubscriptionValidationException.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\API\REST\V3\Routes\Subscriptions\Exceptions; |
| 4 | |
| 5 | use Exception; |
| 6 | |
| 7 | /** |
| 8 | * @since 4.8.0 |
| 9 | */ |
| 10 | class SubscriptionValidationException extends Exception |
| 11 | { |
| 12 | /** |
| 13 | * @var string |
| 14 | */ |
| 15 | private $errorCode; |
| 16 | |
| 17 | /** |
| 18 | * @var int |
| 19 | */ |
| 20 | private $statusCode; |
| 21 | |
| 22 | /** |
| 23 | * @since 4.8.0 |
| 24 | * |
| 25 | * @param string $message |
| 26 | * @param string $errorCode |
| 27 | * @param int $statusCode |
| 28 | * @param Exception|null $previous |
| 29 | */ |
| 30 | public function __construct(string $message, string $errorCode, int $statusCode = 400, Exception $previous = null) |
| 31 | { |
| 32 | parent::__construct($message, 0, $previous); |
| 33 | $this->errorCode = $errorCode; |
| 34 | $this->statusCode = $statusCode; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get the error code |
| 39 | * |
| 40 | * @since 4.8.0 |
| 41 | * |
| 42 | * @return string |
| 43 | */ |
| 44 | public function getErrorCode(): string |
| 45 | { |
| 46 | return $this->errorCode; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get the HTTP status code |
| 51 | * |
| 52 | * @since 4.8.0 |
| 53 | * |
| 54 | * @return int |
| 55 | */ |
| 56 | public function getStatusCode(): int |
| 57 | { |
| 58 | return $this->statusCode; |
| 59 | } |
| 60 | } |
| 61 |