| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\API\REST\V3\Routes\Donations\Exceptions; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 4.8.0 |
| 9 |
*/ |
| 10 |
class DonationValidationException 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.17.0 Declare the nullable parameter explicitly. |
| 24 |
* @since 4.8.0 |
| 25 |
* |
| 26 |
* @param string $message |
| 27 |
* @param string $errorCode |
| 28 |
* @param int $statusCode |
| 29 |
* @param Exception|null $previous |
| 30 |
*/ |
| 31 |
public function __construct(string $message, string $errorCode, int $statusCode = 400, ?Exception $previous = null) |
| 32 |
{ |
| 33 |
parent::__construct($message, 0, $previous); |
| 34 |
$this->errorCode = $errorCode; |
| 35 |
$this->statusCode = $statusCode; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Get the error code |
| 40 |
* |
| 41 |
* @since 4.8.0 |
| 42 |
* |
| 43 |
* @return string |
| 44 |
*/ |
| 45 |
public function getErrorCode(): string |
| 46 |
{ |
| 47 |
return $this->errorCode; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Get the HTTP status code |
| 52 |
* |
| 53 |
* @since 4.8.0 |
| 54 |
* |
| 55 |
* @return int |
| 56 |
*/ |
| 57 |
public function getStatusCode(): int |
| 58 |
{ |
| 59 |
return $this->statusCode; |
| 60 |
} |
| 61 |
} |
| 62 |
|