WordPress at a glance
function is not described

WP_Error::get_error_messages() public WP 2.1.0

Retrieves all error messages, or the error messages for the given error code.

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

No Hooks.

Return

Array. Error strings on success, or empty array if there are none.

Usage

$WP_Error = new WP_Error();
$WP_Error->get_error_messages( $code );
$code(string|int)
Retrieve messages matching code, if exists.

Changelog

Since 2.1.0 Introduced.

Code of WP_Error::get_error_messages() WP 5.7.1

<?php
public function get_error_messages( $code = '' ) {
	// Return all messages if no code specified.
	if ( empty( $code ) ) {
		$all_messages = array();
		foreach ( (array) $this->errors as $code => $messages ) {
			$all_messages = array_merge( $all_messages, $messages );
		}

		return $all_messages;
	}

	if ( isset( $this->errors[ $code ] ) ) {
		return $this->errors[ $code ];
	} else {
		return array();
	}
}