| 1 |
<?php |
| 2 |
/** |
| 3 |
* Extends MainWP Exception |
| 4 |
* |
| 5 |
* Grabs $extra and stores it in $messageExtra. |
| 6 |
* |
| 7 |
* @package MainWP/Dashboard |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace MainWP\Dashboard; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class MainWP_Exception |
| 14 |
* |
| 15 |
* @package MainWP\Dashboard |
| 16 |
*/ |
| 17 |
class MainWP_Exception extends \Exception { |
| 18 |
|
| 19 |
|
| 20 |
/** |
| 21 |
* Protected variable to hold the extra messages. |
| 22 |
* |
| 23 |
* @var string Error messages. |
| 24 |
*/ |
| 25 |
protected $messageExtra; |
| 26 |
|
| 27 |
/** |
| 28 |
* Protected variable to hold the extra data. |
| 29 |
* |
| 30 |
* @var array data. |
| 31 |
*/ |
| 32 |
protected $data; |
| 33 |
|
| 34 |
/** |
| 35 |
* MainWP_Exception constructor. |
| 36 |
* |
| 37 |
* Grab Exception Message upon creation of the object. |
| 38 |
* |
| 39 |
* @param mixed $message Exception message. |
| 40 |
* @param null $extra Any extra Errors. |
| 41 |
* @param string $errCode Errors code. |
| 42 |
*/ |
| 43 |
public function __construct( $message, $extra = null, $errCode = '' ) { |
| 44 |
parent::__construct( $message ); |
| 45 |
$this->messageExtra = esc_html( $extra ); // add more secure. |
| 46 |
$this->errorCode = esc_html( $errCode ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Method get_message_extra() |
| 51 |
* |
| 52 |
* @return $messageExtra Extra messages. |
| 53 |
*/ |
| 54 |
public function get_message_extra() { |
| 55 |
return $this->messageExtra; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Method get_message_error_code() |
| 60 |
* |
| 61 |
* @return string $errorCode Errors code. |
| 62 |
*/ |
| 63 |
public function get_message_error_code() { |
| 64 |
return $this->errorCode; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Method set_data() |
| 69 |
* |
| 70 |
* @param mixed $data Addition data. |
| 71 |
*/ |
| 72 |
public function set_data( $data ) { |
| 73 |
$this->data = $data; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Method get_data() |
| 78 |
* |
| 79 |
* @return $data Addition data. |
| 80 |
*/ |
| 81 |
public function get_data() { |
| 82 |
return $this->data; |
| 83 |
} |
| 84 |
|
| 85 |
} |
| 86 |
|