[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-error.php (summary)

WordPress Error API.

File Size: 316 lines (8 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Error:: (14 methods):
  __construct()
  get_error_codes()
  get_error_code()
  get_error_messages()
  get_error_message()
  get_error_data()
  has_errors()
  add()
  add_data()
  get_all_error_data()
  remove()
  merge_from()
  export_to()
  copy_errors()


Class: WP_Error  - X-Ref

WordPress Error class.

Container for checking for WordPress errors and error messages. Return
WP_Error and use is_wp_error() to check if this class is returned. Many
core WordPress functions pass this class in the event of an error and
if not handled properly will result in code errors.

__construct( $code = '', $message = '', $data = '' )   X-Ref
Initializes the error.

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.

param: string|int $code    Error code.
param: string     $message Error message.
param: mixed      $data    Optional. Error data. Default empty string.

get_error_codes()   X-Ref
Retrieves all error codes.

return: array List of error codes, if available.

get_error_code()   X-Ref
Retrieves the first error code available.

return: string|int Empty string, if no error codes.

get_error_messages( $code = '' )   X-Ref
Retrieves all error messages, or the error messages for the given error code.

param: string|int $code Optional. Error code to retrieve the messages for.
return: string[] Error strings on success, or empty array if there are none.

get_error_message( $code = '' )   X-Ref
Gets a single error message.

This will get the first message available for the code. If no code is
given then the first code available will be used.

param: string|int $code Optional. Error code to retrieve the message for.
return: string The error message.

get_error_data( $code = '' )   X-Ref
Retrieves the most recently added error data for an error code.

param: string|int $code Optional. Error code. Default empty string.
return: mixed Error data, if it exists.

has_errors()   X-Ref
Verifies if the instance contains errors.

return: bool If the instance contains errors.

add( $code, $message, $data = '' )   X-Ref
Adds an error or appends an additional message to an existing error.

param: string|int $code    Error code.
param: string     $message Error message.
param: mixed      $data    Optional. Error data. Default empty string.

add_data( $data, $code = '' )   X-Ref
Adds data to an error with the given code.

param: mixed      $data Error data.
param: string|int $code Error code.

get_all_error_data( $code = '' )   X-Ref
Retrieves all error data for an error code in the order in which the data was added.

param: string|int $code Error code.
return: mixed[] Array of error data, if it exists.

remove( $code )   X-Ref
Removes the specified error.

This function removes all error messages associated with the specified
error code, along with any error data for that code.

param: string|int $code Error code.

merge_from( WP_Error $error )   X-Ref
Merges the errors in the given error object into this one.

param: WP_Error $error Error object to merge.

export_to( WP_Error $error )   X-Ref
Exports the errors in this object into the given one.

param: WP_Error $error Error object to export into.

copy_errors( WP_Error $from, WP_Error $to )   X-Ref
Copies errors from one WP_Error instance to another.

param: WP_Error $from The WP_Error to copy from.
param: WP_Error $to   The WP_Error to copy to.



Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref