get_error_data(); $data = is_array($data) ? $data : []; $candidates = [ $data['oauth_error'] ?? '', $data['error_code'] ?? '', $data['reason'] ?? '', $error->get_error_code(), $data['status'] ?? '', ]; $generic = ['api_error', 'api_response_error', 'api_request_failed', 'request_failed']; foreach (['VASP_ERROR_API_RESPONSE_ERROR', 'VASP_ERROR_API_REQUEST_FAILED'] as $constant) { if (defined($constant)) { $generic[] = sanitize_key((string) constant($constant)); } } $fallback = ''; foreach ($candidates as $candidate) { $code = substr(sanitize_key((string) $candidate), 0, 64); if ($code === '') { continue; } if ($fallback === '') { $fallback = $code; } if (ctype_digit($code) && ((int) $code < 400 || (int) $code > 599)) { continue; } if (!in_array($code, $generic, true)) { return $code; } } return $fallback !== '' ? $fallback : VASP_USER_ERROR_UNKNOWN; } /** Discard external error details before logging, persistence, or display. */ function vasp_normalize_external_error_message($message, $fallback = '') { return $fallback !== '' ? $fallback : __('The service returned an unexpected response.', 'valuespace'); } /** * Get user-friendly outcome label * * @param string $category Error category * @return string Localized outcome label */ function vasp_get_outcome_label($category) { $labels = [ VASP_USER_ERROR_CONNECTION => __('Connection issue', 'valuespace'), VASP_USER_ERROR_AUTHENTICATION => __('Sign-in issue', 'valuespace'), VASP_USER_ERROR_PERMISSION => __('Permission needed', 'valuespace'), VASP_USER_ERROR_CONFIGURATION => __('Setup needed', 'valuespace'), VASP_USER_ERROR_DEPENDENCY => __('Requirement missing', 'valuespace'), VASP_USER_ERROR_DENIED => __('Authorization not completed', 'valuespace'), VASP_USER_ERROR_UNKNOWN => __('Something went wrong', 'valuespace'), 'info' => __('Already connected', 'valuespace') ]; return $labels[$category] ?? $labels[VASP_USER_ERROR_UNKNOWN]; } /** * Map technical error to user-friendly category and message * * @param string $technical_error_code Technical error code * @param string $technical_message Technical error message * @param string $integration Integration name (valuespace, wordpress, woocommerce) * @return array ['category' => string, 'description' => string, 'hint' => string, 'can_retry' => bool] */ function vasp_map_error_to_user_friendly($technical_error_code, $technical_message, $integration = 'valuespace') { $error_mapping = vasp_get_error_mapping(); // Stable codes are authoritative. Prose is used only as a legacy fallback // for older callers that did not preserve a code. $normalized_code = strtolower(trim((string) $technical_error_code)); if (isset($error_mapping[$normalized_code])) { $user_error = $error_mapping[$normalized_code]; return [ 'category' => $user_error['category'], 'description' => $user_error['description'], 'diagnostic' => $user_error['diagnostic'] ?? $user_error['description'], 'hint' => $user_error['hint'] ?? '', 'can_retry' => $user_error['can_retry'] ?? true, ]; } if ($normalized_code === '' || in_array($normalized_code, ['error', 'unknown', VASP_USER_ERROR_UNKNOWN], true)) { $search_text = strtolower((string) $technical_message); foreach (vasp_get_legacy_error_patterns() as $pattern) { $user_error = $error_mapping[$pattern]; if ($search_text !== '' && strpos($search_text, strtolower($pattern)) !== false) { return [ 'category' => $user_error['category'], 'description' => $user_error['description'], 'diagnostic' => $user_error['diagnostic'] ?? $user_error['description'], 'hint' => $user_error['hint'] ?? '', 'can_retry' => $user_error['can_retry'] ?? true ]; } } } if ($integration === 'catalog_sync') { return [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('The catalog update stopped before it finished.', 'valuespace'), 'diagnostic' => __('The catalog synchronization stopped during the recorded operation.', 'valuespace'), 'hint' => __('Retry the catalog update.', 'valuespace'), 'can_retry' => true, ]; } // Legacy errors without a code are assumed to be availability failures. if (($normalized_code === '' || in_array($normalized_code, ['error', 'unknown', VASP_USER_ERROR_UNKNOWN], true)) && (empty($technical_message) || $technical_message === 'An error occurred')) { return [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('The service could not be reached', 'valuespace'), 'diagnostic' => __('The service could not be reached', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ]; } // Default unknown error return [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('The requested operation could not be completed.', 'valuespace'), 'diagnostic' => __('The synchronization stopped without a recognized failure reason.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ]; } /** Curated prose matching retained only for legacy errors that have no stable code. */ function vasp_get_legacy_error_patterns(): array { return [ 'could not resolve host', 'connection refused', 'connection timed out', 'failed to connect', 'network is unreachable', 'ssl certificate', 'woocommerce plugin is not installed', 'bad gateway', 'service unavailable', 'gateway timeout', ]; } /** * Build a safe, actionable response for an integration disconnect failure. * * Technical details are used only for classification and are never returned to * the browser. Remote acknowledgement is required before local state is removed, * so every failure can truthfully confirm that the connection was preserved. * * @param WP_Error $error Technical operation error. * @param string $integration wordpress or woocommerce. * @return array{message:string,hint:string,code:string,integration:string} */ function vasp_format_disconnect_failure(WP_Error $error, string $integration): array { $integration = in_array($integration, ['wordpress', 'woocommerce'], true) ? $integration : 'wordpress'; $label = $integration === 'woocommerce' ? __('WooCommerce', 'valuespace') : __('WordPress', 'valuespace'); $user_error = vasp_map_error_to_user_friendly( $error->get_error_code(), $error->get_error_message(), $integration ); return [ /* translators: %s: Integration display name. */ 'message' => sprintf(__('%s could not be disconnected.', 'valuespace'), $label), 'hint' => (string) ($user_error['hint'] ?? __('Your existing connection has not been changed.', 'valuespace')), 'code' => sanitize_key((string) $error->get_error_code()), 'integration' => $integration, ]; } /** * Get error mapping configuration * * Maps technical error patterns to user-friendly messages * * @return array Error mapping configuration */ function vasp_get_error_mapping() { return [ // OAuth and connection-establishment responses. 'invalid_grant' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your ValueSpace connection needs to be renewed.', 'valuespace'), 'hint' => __('Reconnect from the settings page.', 'valuespace'), 'can_retry' => false, ], 'invalid_client' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('This connection could not be verified.', 'valuespace'), 'hint' => __('Reconnect from the settings page.', 'valuespace'), 'can_retry' => false, ], 'unauthorized_client' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('This site is not ready to connect to ValueSpace.', 'valuespace'), 'hint' => __('Reconnect from the settings page.', 'valuespace'), 'can_retry' => false, ], 'access_denied' => [ 'category' => VASP_USER_ERROR_DENIED, 'description' => __('Authorization was not completed.', 'valuespace'), 'hint' => __('Start the connection again when you are ready.', 'valuespace'), 'can_retry' => true, ], 'server_error' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true, ], 'temporarily_unavailable' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true, ], 'pipeline_run_id_required' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('The catalog update could not start.', 'valuespace'), 'hint' => __('Try again in a moment.', 'valuespace'), 'can_retry' => true, ], 'invalid_response' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('WordPress could not process the synchronization response.', 'valuespace'), 'diagnostic' => __('WordPress could not process the synchronization response it received.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true, ], 'wordpress_ingestion_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('WordPress content could not be updated in ValueSpace.', 'valuespace'), 'diagnostic' => __('WordPress content processing stopped before it finished.', 'valuespace'), 'hint' => __('Retry the WordPress content update.', 'valuespace'), 'can_retry' => true, ], 'unsupported_schema' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('Visitor events could not be sent with this plugin version.', 'valuespace'), 'diagnostic' => __('The visitor event format used by this plugin version was not accepted.', 'valuespace'), 'hint' => __('Update the ValueSpace plugin, then try again.', 'valuespace'), 'can_retry' => false, ], 'worker_interrupted' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('The synchronization stopped before it finished.', 'valuespace'), 'diagnostic' => __('WordPress stopped the background synchronization before the current operation finished.', 'valuespace'), 'hint' => __('Start the synchronization again.', 'valuespace'), 'can_retry' => true, ], // Catalog synchronization and server-side search preparation. 'catalog_product_integration_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('Some catalog products could not be processed.', 'valuespace'), 'diagnostic' => __('Catalog product processing stopped before it finished.', 'valuespace'), 'hint' => __('Retry the catalog update.', 'valuespace'), 'can_retry' => true ], 'catalog_image_integration_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('Some product images could not be processed.', 'valuespace'), 'diagnostic' => __('Product image processing stopped before it finished.', 'valuespace'), 'hint' => __('Retry the catalog update.', 'valuespace'), 'can_retry' => true ], 'catalog_product_enrichment_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('Search information could not be prepared for some products.', 'valuespace'), 'diagnostic' => __('Product search preparation stopped before it finished.', 'valuespace'), 'hint' => __('Retry the catalog update later.', 'valuespace'), 'can_retry' => true ], 'catalog_brand_enrichment_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('Search information could not be prepared for some brands.', 'valuespace'), 'diagnostic' => __('Brand search preparation stopped before it finished.', 'valuespace'), 'hint' => __('Retry the catalog update later.', 'valuespace'), 'can_retry' => true ], 'catalog_image_enrichment_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('Search information could not be prepared for some product images.', 'valuespace'), 'diagnostic' => __('Product image search preparation stopped before it finished.', 'valuespace'), 'hint' => __('Retry the catalog update later.', 'valuespace'), 'can_retry' => true ], 'catalog_synchronization_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('The catalog update stopped before it finished.', 'valuespace'), 'diagnostic' => __('The catalog synchronization stopped before the current operation completed.', 'valuespace'), 'hint' => __('Retry the catalog update.', 'valuespace'), 'can_retry' => true ], 'image_storage_unavailable' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('Image storage is temporarily unavailable.', 'valuespace'), 'diagnostic' => __('A product image could not be stored during synchronization.', 'valuespace'), 'hint' => __('Retry the update.', 'valuespace'), 'can_retry' => true ], 'image_source_missing' => [ 'category' => VASP_USER_ERROR_DEPENDENCY, 'description' => __('A product image is missing from the WordPress Media Library.', 'valuespace'), 'diagnostic' => __('WordPress could not find the product image file selected for synchronization.', 'valuespace'), 'hint' => __('Restore or replace the affected image, then retry the update.', 'valuespace'), 'can_retry' => false ], 'image_source_read_failed' => [ 'category' => VASP_USER_ERROR_PERMISSION, 'description' => __('WordPress could not read a product image file.', 'valuespace'), 'diagnostic' => __('WordPress found the product image but could not read its file.', 'valuespace'), 'hint' => __('Check the affected image file or replace it, then retry the update.', 'valuespace'), 'can_retry' => false ], 'image_source_download_failed' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('WordPress could not load a product image.', 'valuespace'), 'diagnostic' => __('WordPress could not download the product image selected for synchronization.', 'valuespace'), 'hint' => __('Check that the affected image is available, then retry the update.', 'valuespace'), 'can_retry' => false ], 'image_source_too_large' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('A product image is too large to send.', 'valuespace'), 'diagnostic' => __('WordPress could not prepare the product image within the upload size limit.', 'valuespace'), 'hint' => __('Replace the affected image with a smaller file, then retry the update.', 'valuespace'), 'can_retry' => false ], // WordPress Dashboard SSO errors 'wordpress_admin_access_required' => [ 'category' => VASP_USER_ERROR_PERMISSION, 'description' => __('Only administrators can access the dashboard.', 'valuespace'), 'hint' => '', 'can_retry' => true ], 'valuespace_connection_failed' => [ 'category' => VASP_USER_ERROR_UNKNOWN, 'description' => __('Sign-in could not be completed.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], // Connection errors - most specific first 'could not resolve host' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'connection refused' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'connection timed out' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('The connection to ValueSpace AI timed out.', 'valuespace'), 'hint' => __('Please try again in a few minutes.', 'valuespace'), 'can_retry' => true ], 'failed to connect' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'network is unreachable' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('Your internet connection appears to be offline', 'valuespace'), 'hint' => __('Please check your network and try again.', 'valuespace'), 'can_retry' => true ], 'ssl certificate' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('A secure connection could not be established', 'valuespace'), 'hint' => __('Please contact support if this keeps happening.', 'valuespace'), 'can_retry' => false ], 'timeout' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('The connection to ValueSpace AI timed out.', 'valuespace'), 'hint' => __('Please try again in a few minutes.', 'valuespace'), 'can_retry' => true ], 'http_request_failed' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'api_call_failed' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Please try again in a moment.', 'valuespace'), 'can_retry' => true ], 'request_failed' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'connection' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], // Credentials / session errors // "credentials" used throughout instead of technical "token" terminology. 'invalid_token' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your ValueSpace connection needs to be renewed', 'valuespace'), 'hint' => __('Please reconnect this integration.', 'valuespace'), 'can_retry' => true ], 'token_expired' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your ValueSpace connection has expired', 'valuespace'), 'hint' => __('Please reconnect this integration to continue.', 'valuespace'), 'can_retry' => true ], 'token_revoked' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your ValueSpace connection was disconnected', 'valuespace'), 'hint' => __('Please reconnect this integration to restore access.', 'valuespace'), 'can_retry' => true ], 'token_not_found' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('No saved connection was found for this integration', 'valuespace'), 'hint' => __('Please connect your account to get started.', 'valuespace'), 'can_retry' => true ], 'refresh_token_expired' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your connection could not be renewed automatically', 'valuespace'), 'hint' => __('Please reconnect this integration to continue.', 'valuespace'), 'can_retry' => true ], 'refresh_token_invalid' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your connection could not be renewed automatically', 'valuespace'), 'hint' => __('Please reconnect this integration.', 'valuespace'), 'can_retry' => true ], 'token_refresh_failed' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your connection could not be renewed automatically', 'valuespace'), 'hint' => __('Please reconnect to continue.', 'valuespace'), 'can_retry' => true ], 'no_refresh_token' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('This connection needs to be renewed', 'valuespace'), 'hint' => __('Please reconnect this integration.', 'valuespace'), 'can_retry' => true ], 'unauthorized' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('This connection could not be verified.', 'valuespace'), 'hint' => __('Please reconnect to restore access.', 'valuespace'), 'can_retry' => true ], // Broad fallback — network/service failures match 'connection' first. 'token' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Could not verify this connection', 'valuespace'), 'hint' => __('Please reconnect to restore your connection.', 'valuespace'), 'can_retry' => true ], 'expired' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your ValueSpace connection has expired', 'valuespace'), 'hint' => __('Please reconnect to continue.', 'valuespace'), 'can_retry' => true ], 'invalid_credentials' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('This connection needs to be renewed', 'valuespace'), 'hint' => __('Please reconnect to restore access.', 'valuespace'), 'can_retry' => true ], 'missing_credentials' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('No saved connection was found', 'valuespace'), 'hint' => __('Please connect your account to get started.', 'valuespace'), 'can_retry' => true ], 'refresh_failed' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your connection could not be renewed automatically', 'valuespace'), 'hint' => __('Please reconnect to continue.', 'valuespace'), 'can_retry' => true ], 'authentication_failed' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Sign-in was not completed', 'valuespace'), 'hint' => __('Please reconnect your account.', 'valuespace'), 'can_retry' => true ], // Permission errors 'permission' => [ 'category' => VASP_USER_ERROR_PERMISSION, 'description' => __('This action needs additional permission', 'valuespace'), 'hint' => __('Ask a WordPress administrator to perform this action.', 'valuespace'), 'can_retry' => false ], '403' => [ 'category' => VASP_USER_ERROR_PERMISSION, 'description' => __('This connection does not have permission for that action', 'valuespace'), 'hint' => __('Contact ValueSpace support.', 'valuespace'), 'can_retry' => false ], '401' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('Your ValueSpace connection has expired', 'valuespace'), 'hint' => __('Please reconnect to continue.', 'valuespace'), 'can_retry' => true ], // Configuration errors 'not_configured' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('This integration has not been set up yet', 'valuespace'), 'hint' => __('Please complete the setup in plugin settings.', 'valuespace'), 'can_retry' => false ], 'missing_config' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('Some required settings are missing', 'valuespace'), 'hint' => __('Please complete the plugin setup.', 'valuespace'), 'can_retry' => false ], 'endpoint' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('The service address is not configured correctly', 'valuespace'), 'hint' => __('Please contact support for assistance.', 'valuespace'), 'can_retry' => false ], // Dependency / prerequisite errors 'not_connected' => [ 'category' => VASP_USER_ERROR_DEPENDENCY, 'description' => __('A required integration is not connected yet', 'valuespace'), 'hint' => __('Please connect the required integrations first.', 'valuespace'), 'can_retry' => false ], 'dependency' => [ 'category' => VASP_USER_ERROR_DEPENDENCY, 'description' => __('A required service could not be reached', 'valuespace'), 'hint' => __('Restore the required integration, then retry.', 'valuespace'), 'can_retry' => false ], 'woocommerce plugin is not installed' => [ 'category' => VASP_USER_ERROR_DEPENDENCY, 'description' => __('WooCommerce needs to be installed first', 'valuespace'), 'hint' => __('Please install and activate WooCommerce to continue.', 'valuespace'), 'can_retry' => false ], // Already connected 'already_connected' => [ 'category' => 'info', 'description' => __('This service is already connected', 'valuespace'), 'hint' => __('No action is needed.', 'valuespace'), 'can_retry' => false ], // User declined authorization 'denied' => [ 'category' => VASP_USER_ERROR_DENIED, 'description' => __('Authorization was not completed', 'valuespace'), 'hint' => __('Click the connect button to try again.', 'valuespace'), 'can_retry' => true ], // Security / CSRF check failed 'invalid_state' => [ 'category' => VASP_USER_ERROR_AUTHENTICATION, 'description' => __('The connection security check did not complete', 'valuespace'), 'hint' => __('Please try connecting again.', 'valuespace'), 'can_retry' => true ], // Server errors - HTTP status codes '502' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], '503' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], '504' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('The connection to ValueSpace AI timed out.', 'valuespace'), 'hint' => __('Please try again in a few minutes.', 'valuespace'), 'can_retry' => true ], '500' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Please try again in a few minutes.', 'valuespace'), 'can_retry' => true ], '404' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('The requested service could not be found.', 'valuespace'), 'hint' => __('Please contact support if this keeps happening.', 'valuespace'), 'can_retry' => true ], '429' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('This request was temporarily limited.', 'valuespace'), 'hint' => __('Please wait a few minutes before trying again.', 'valuespace'), 'can_retry' => true ], 'bad gateway' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'service unavailable' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('We are having trouble connecting to ValueSpace AI right now.', 'valuespace'), 'hint' => __('Try again later.', 'valuespace'), 'can_retry' => true ], 'gateway timeout' => [ 'category' => VASP_USER_ERROR_CONNECTION, 'description' => __('The connection to ValueSpace AI timed out.', 'valuespace'), 'hint' => __('Please try again in a few minutes.', 'valuespace'), 'can_retry' => true ], // Encryption errors 'encrypt' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('A secure storage issue occurred', 'valuespace'), 'hint' => __('Please contact support for assistance.', 'valuespace'), 'can_retry' => false ], 'decrypt' => [ 'category' => VASP_USER_ERROR_CONFIGURATION, 'description' => __('A secure storage issue occurred', 'valuespace'), 'hint' => __('Please contact support for assistance.', 'valuespace'), 'can_retry' => false ] ]; } /** * Get integration display name * * @param string $integration Integration name * @return string Display name */ function vasp_get_integration_display_name($integration) { $integration_labels = [ 'valuespace' => __('ValueSpace', 'valuespace'), 'wordpress' => __('Integration with WordPress', 'valuespace'), 'woocommerce' => __('Integration with WooCommerce', 'valuespace'), 'catalog_sync'=> __('E-commerce Data Upload', 'valuespace') ]; return $integration_labels[$integration] ?? ucfirst($integration); }