Automattic\WooCommerce\Admin\API

NavigationFavorites::prepare_error()protectedWC 1.0

Accept an instance of WP_Error and add the appropriate data for REST transit.

Method of the class: NavigationFavorites{}

No Hooks.

Return

WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_error( $error );
$error(WP_Error) (required)
Error to prepare.

NavigationFavorites::prepare_error() code WC 8.7.0

protected function prepare_error( $error ) {
	if ( ! is_wp_error( $error ) ) {
		return $error;
	}

	$error->add_data(
		array(
			'status' => $this->error_to_status_map[ $error->get_error_code() ] ?? 500,
		)
	);

	return $error;
}