rest_format_combining_operation_error()

最后更新于:2021-11-27 23:35:38

rest_format_combining_operation_error( string$param, array$error)

Formats a combining operation error into a GC_Error object.

参数

$param

(string) (Required) The parameter name.

$error

(array) (Required) The error details.

响应

(GC_Error)

源文件

文件: gc-includes/rest-api.php

function rest_format_combining_operation_error( $param, $error ) {
	$position = $error['index'];
	$reason   = $error['error_object']->get_error_message();

	if ( isset( $error['schema']['title'] ) ) {
		$title = $error['schema']['title'];

		return new GC_Error(
			'rest_no_matching_schema',
			/* translators: 1: Parameter, 2: Schema title, 3: Reason. */
			sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ),
			array( 'position' => $position )
		);
	}

	return new GC_Error(
		'rest_no_matching_schema',
		/* translators: 1: Parameter, 2: Reason. */
		sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ),
		array( 'position' => $position )
	);
}