From 5f4961b02a97d5ea495a6eedc00fc8f27540d32b Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Mon, 6 May 2024 17:41:11 +0530 Subject: [PATCH] Fix error inconsistencies --- includes/Utils/AISearchUtil.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/Utils/AISearchUtil.php b/includes/Utils/AISearchUtil.php index 464abee..292e664 100644 --- a/includes/Utils/AISearchUtil.php +++ b/includes/Utils/AISearchUtil.php @@ -80,6 +80,12 @@ public static function get_search_results( $parsed_response = json_decode( wp_remote_retrieve_body( $response ), true ); + if ( isset( $parsed_response['status'] ) && 'Failure' === $parsed_response['status'] ) { + return array( + 'error' => __( 'We are unable to process the request at this moment' ), + ); + } + try { return array( 'result' => $parsed_response['payload']['choices'],