| 1 |
<?php |
| 2 |
/** |
| 3 |
* Base custom exception for the WAF package. |
| 4 |
* |
| 5 |
* @since 0.10.1 |
| 6 |
* |
| 7 |
* @package automattic/jetpack-waf |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Automattic\Jetpack\Waf; |
| 11 |
|
| 12 |
use Exception; |
| 13 |
use WP_Error; |
| 14 |
|
| 15 |
/** |
| 16 |
* WAF exception. |
| 17 |
*/ |
| 18 |
class Waf_Exception extends Exception { |
| 19 |
|
| 20 |
/** |
| 21 |
* Error slug which maps to WP_Error::$code. |
| 22 |
* |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
const SLUG = 'waf_error'; |
| 26 |
|
| 27 |
/** |
| 28 |
* Convert the exception into a WP_Error object. |
| 29 |
* |
| 30 |
* @return WP_Error |
| 31 |
*/ |
| 32 |
public function get_wp_error() { |
| 33 |
return new WP_Error( static::SLUG, $this->getMessage() ); |
| 34 |
} |
| 35 |
} |
| 36 |
|