Automattic\WooCommerce\StoreApi\Routes\V1

AbstractCartRoute::get_cart_session_error_response │ protected │ WC 1.0

Convert a failure during cart session loading into a client-safe error response.

Error details are returned only to managers when debug details are enabled.

Method of the class: AbstractCartRoute{}

No Hooks.

Returns

\WP_REST_Response. The error response to return to the client.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_cart_session_error_response( $error );
$error(Throwable) (required)
The error that occurred while loading the cart session.

AbstractCartRoute::get_cart_session_error_response() code WC 11.3.0

protected function get_cart_session_error_response( \Throwable $error ) {
	return $this->error_to_response(
		UnexpectedErrorResponse::create(
			$error,
			sprintf( '%s while loading the cart session', static::class ),
			__( 'The cart could not be loaded. Please try again.', 'woocommerce' )
		)
	);
}