*/ private array $errors; /** * Builds the exception with its error list. * * @since 1.0.0 * * @param string $message A human-readable summary. * @param array $errors The individual field-level messages. */ public function __construct( string $message, array $errors = array() ) { parent::__construct( $message ); $this->errors = $errors; } /** * Builds the exception from an error list. * * @since 1.0.0 * * @param array $errors The individual field-level messages. * @return self */ public static function withErrors( array $errors ): self { return new self( implode( ' ', $errors ), $errors ); } /** * The individual validation messages. * * @since 1.0.0 * * @return array The field-level error messages. */ public function getErrors(): array { return $this->errors; } }