Automattic\WooCommerce\Internal

RestApiControllerBase::internal_wp_error()protectedWC 1.0

Return an WP_Error object for an internal server error, with exception information if the current user is an admin.

Метод класса: RestApiControllerBase{}

Хуков нет.

Возвращает

WP_Error.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->internal_wp_error( $exception ): WP_Error;
$exception(Exception) (обязательный)
The exception to maybe include information from.

Код RestApiControllerBase::internal_wp_error() WC 9.7.1

protected function internal_wp_error( Exception $exception ): WP_Error {
	$data = array( 'status' => 500 );
	if ( current_user_can( 'manage_woocommerce' ) ) {
		$data['exception_class']   = get_class( $exception );
		$data['exception_message'] = $exception->getMessage();
		$data['exception_trace']   = (array) $exception->getTrace();
	}
	$data['exception_message'] = $exception->getMessage();

	return new WP_Error( 'woocommerce_rest_internal_error', __( 'Internal server error', 'woocommerce' ), $data );
}