<?php
/**
 * Sync Exception Class
 *
 * @package ShopExplorer\Exceptions
 * @since 1.0.0
 */

namespace SHOPEXPLORER\Exceptions;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Sync exception class
 *
 * @since 1.0.0
 */
class SHOPEX_SyncException extends SHOPEX_ShopExplorerException {

	/**
	 * Error type
	 *
	 * @var string
	 */
	protected $error_type = 'sync';

	/**
	 * Sync error codes
	 */
	const ERROR_SYNC_FAILED = 4001;
	const ERROR_CONFLICT_DETECTED = 4002;
	const ERROR_DATA_MISMATCH = 4003;
	const ERROR_TIMEOUT = 4004;
	const ERROR_RATE_LIMIT = 4005;
	const ERROR_INVALID_DATA = 4006;
	const ERROR_CONNECTION_FAILED = 4007;

	/**
	 * Get user-friendly error message
	 *
	 * @return string
	 */
	public function get_user_message() {
		switch ( $this->getCode() ) {
			case self::ERROR_SYNC_FAILED:
				return __( 'Data synchronization failed.', 'shop-explorer' );

			case self::ERROR_CONFLICT_DETECTED:
				return __( 'Data conflict detected during synchronization.', 'shop-explorer' );

			case self::ERROR_DATA_MISMATCH:
				return __( 'Data mismatch between systems.', 'shop-explorer' );

			case self::ERROR_TIMEOUT:
				return __( 'Synchronization timed out.', 'shop-explorer' );

			case self::ERROR_RATE_LIMIT:
				return __( 'Rate limit exceeded. Please try again later.', 'shop-explorer' );

			case self::ERROR_INVALID_DATA:
				return __( 'Invalid data format for synchronization.', 'shop-explorer' );

			case self::ERROR_CONNECTION_FAILED:
				return __( 'Failed to connect to synchronization service.', 'shop-explorer' );

			default:
				return __( 'Synchronization error occurred.', 'shop-explorer' );
		}
	}
}
