WordPress at a glance
function is not described

WP_Error::add_data() public WP 2.1.0

Adds data to an error with the given code.

{} It's a method of the class: WP_Error{}

No Hooks.

Return

null. Null. Nothing.

Usage

$WP_Error = new WP_Error();
$WP_Error->add_data( $data, $code );
$data(mixed) (required)
Error data.
$code(string|int)
Error code.

Changelog

Since 2.1.0 Introduced.
Since 5.6.0 Errors can now contain more than one item of error data. {@see WP_Error::$additional_data}.

Code of WP_Error::add_data() WP 5.7

<?php
public function add_data( $data, $code = '' ) {
	if ( empty( $code ) ) {
		$code = $this->get_error_code();
	}

	if ( isset( $this->error_data[ $code ] ) ) {
		$this->additional_data[ $code ][] = $this->error_data[ $code ];
	}

	$this->error_data[ $code ] = $data;
}