WordPress at a glance
function is not described

WP_Error::add() public WP 2.1.0

Adds an error or appends an additional message to an existing error.

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

Hooks from the method
Return

null. Null. Nothing.

Usage

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

Changelog

Since 2.1.0 Introduced.

Code of WP_Error::add() WP 5.7

<?php
public function add( $code, $message, $data = '' ) {
	$this->errors[ $code ][] = $message;

	if ( ! empty( $data ) ) {
		$this->add_data( $data, $code );
	}

	/**
	 * Fires when an error is added to a WP_Error object.
	 *
	 * @since 5.6.0
	 *
	 * @param string|int $code     Error code.
	 * @param string     $message  Error message.
	 * @param mixed      $data     Error data. Might be empty.
	 * @param WP_Error   $wp_error The WP_Error object.
	 */
	do_action( 'wp_error_added', $code, $message, $data, $this );
}