Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Waf_Exception
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 get_wp_error
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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
10namespace Automattic\Jetpack\Waf;
11
12use Exception;
13use WP_Error;
14
15/**
16 * WAF exception.
17 */
18class 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}