$data More for the client, e.g. alternatives. */ public function __construct( public readonly string $error_code, string $message, public readonly int $status = 400, public readonly array $data = array() ) { parent::__construct( $message ); } /** * As a WP_Error for a REST response. */ public function to_error(): \WP_Error { return new \WP_Error( $this->error_code, $this->getMessage(), array_merge( $this->data, array( 'status' => $this->status ) ) ); } }