Automattic\WooCommerce\StoreApi\Routes\V1
AbstractCartRoute::get_cart_session_error_response
Convert a failure during cart session loading into a client-safe error response.
The original error is logged rather than returned, so nothing internal reaches the client.
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() AbstractCartRoute::get cart session error response code WC 11.2.2
protected function get_cart_session_error_response( \Throwable $error ) {
wc_get_logger()->error(
sprintf(
'Store API could not load the cart session: %1$s in %2$s:%3$d',
$error->getMessage(),
$error->getFile(),
$error->getLine()
),
array(
'source' => 'store-api',
'exception' => $error,
)
);
return $this->error_to_response(
$this->get_route_error_response(
'woocommerce_rest_unknown_server_error',
__( 'The cart could not be loaded. Please try again.', 'woocommerce' ),
500
)
);
}