MailPoet\EmailEditor\Validator

Validation_Exception{}WC 1.0

Exception thrown when validation fails.

No Hooks.

Usage

$Validation_Exception = new Validation_Exception();
// use class methods

Methods

  1. public static create_from_wp_error( WP_Error $wp_error )
  2. public get_wp_error()

Validation_Exception{} code WC 9.8.2

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;
	}
}