wordpress / latest / classes / wp_error / __construct.html

WP_Error::__construct( string|int $code = '', string $message = '', mixed $data = '' )

Initializes the error.

Description

If $code is empty, the other parameters will be ignored.
When $code is not empty, $message will be used even if it is empty. The $data parameter will be used only if it is not empty.

Though the class is constructed with a single error code and message, multiple codes can be added using the add() method.

Parameters

$code string|int Optional
Error code.

Default: ''

$message string Optional
Error message.

Default: ''

$data mixed Optional
Error data.

Default: ''

Source

File: wp-includes/class-wp-error.php. View all references

public function __construct( $code = '', $message = '', $data = '' ) {
	if ( empty( $code ) ) {
		return;
	}

	$this->add( $code, $message, $data );
}

Uses

Uses Description

Used By

Used By Description

Changelog

Version Description
2.1.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_error/__construct