Automattic\WooCommerce\EmailEditor\Validator
Validation_Exception{}└─ UnexpectedValueException
Exception thrown when validation fails.
No Hooks.
Usage
$Validation_Exception = new Validation_Exception(); // use class methods
Methods
- public static create_from_wp_error( WP_Error $wp_error )
- public get_wp_error()
Validation_Exception{} Validation Exception{} code WC 10.8.1
class Validation_Exception extends UnexpectedValueException {
/**
* WP_Error instance.
*
* @var WP_Error
*/
protected $wp_error;
/**
* Creates a new instance of the exception.
*
* @param WP_Error $wp_error WP_Error instance.
*/
public static function create_from_wp_error( WP_Error $wp_error ): self {
$exception = self::create()
->withMessage( $wp_error->get_error_message() );
$exception->wp_error = $wp_error;
return $exception;
}
/**
* Returns the WP_Error instance.
*/
public function get_wp_error(): WP_Error {
return $this->wp_error;
}
}