| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPConsole\Exceptions; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
|
| 7 |
class WPConsoleException extends Exception { |
| 8 |
|
| 9 |
/** |
| 10 |
* Error code |
| 11 |
* |
| 12 |
* @since 1.3.0 |
| 13 |
* |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
protected $error_code = ''; |
| 17 |
|
| 18 |
/** |
| 19 |
* Class constructor |
| 20 |
* |
| 21 |
* @since 1.3.0 |
| 22 |
* |
| 23 |
* @param string $error_code |
| 24 |
* @param string $message |
| 25 |
* @param int $status_code |
| 26 |
*/ |
| 27 |
public function __construct( $error_code, $message, $status_code = 422 ) { |
| 28 |
$this->error_code = $error_code; |
| 29 |
|
| 30 |
parent::__construct( $message, $status_code ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Get error code |
| 35 |
* |
| 36 |
* @since 1.3.0 |
| 37 |
* |
| 38 |
* @return string |
| 39 |
*/ |
| 40 |
final public function get_error_code() { |
| 41 |
return $this->error_code; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Get error message |
| 46 |
* |
| 47 |
* @since 1.3.0 |
| 48 |
* |
| 49 |
* @return string |
| 50 |
*/ |
| 51 |
final public function get_message() { |
| 52 |
return $this->getMessage(); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get error status code |
| 57 |
* |
| 58 |
* @since 1.3.0 |
| 59 |
* |
| 60 |
* @return int |
| 61 |
*/ |
| 62 |
final public function get_status_code() { |
| 63 |
return $this->getCode(); |
| 64 |
} |
| 65 |
} |
| 66 |
|