MailPoet\EmailEditor

Exception{}WC 1.0

Frames all exceptions ("$e instanceof MailPoet\EmailEditor\Exception").

No Hooks.

Usage

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

Methods

  1. public __construct(string $message = '', int $code = 0, \Throwable $previous = null)
  2. public static create(\Throwable $previous = null)
  3. public getErrors()
  4. public withCode(int $code)
  5. public withError(string $id, string $error)
  6. public withErrors(array $errors)
  7. public withMessage(string $message)

Exception{} code WC 9.8.1

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

  /** @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;
  }

  public function getErrors(): array {
    return $this->errors;
  }
}