Automattic\WooCommerce\EmailEditor
Exception{}
Frames all exceptions ("$e instanceof Automattic\WooCommerce\EmailEditor\Exception").
No Hooks.
Usage
$Exception = new Exception(); // use class methods
Methods
- public __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
- public static create(?\Throwable $previous = null)
- public getErrors()
- public withCode(int $code)
- public withError(string $id, string $error)
- public withErrors(array $errors)
- public withMessage(string $message)
Exception{} Exception{} code WC 10.5.0
abstract class Exception extends \Exception {
/** @var string[] */
private $errors = [];
final public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null) {
parent::__construct($message, $code, $previous);
}
/** @return static */
public static function create(?\Throwable $previous = null) {
return new static('', 0, $previous);
}
/** @return static */
public function withMessage(string $message) {
$this->message = $message;
return $this;
}
/** @return static */
public function withCode(int $code) {
$this->code = $code;
return $this;
}
/**
* @param string[] $errors
* @return static
*/
public function withErrors(array $errors) {
$this->errors = $errors;
return $this;
}
/** @return static */
public function withError(string $id, string $error) {
$this->errors[$id] = $error;
return $this;
}
/**
* @return string[]
*/
public function getErrors(): array {
return $this->errors;
}
}