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

namespace SHOPEXPLORER\Exceptions;

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

/**
 * Google Sheets exception class
 *
 * @since 1.0.0
 */
class SHOPEX_GoogleSheetsException extends SHOPEX_ShopExplorerException {

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

	/**
	 * Google Sheets error codes
	 */
	const ERROR_AUTH_FAILED = 5001;
	const ERROR_INVALID_CREDENTIALS = 5002;
	const ERROR_SHEET_NOT_FOUND = 5003;
	const ERROR_PERMISSION_DENIED = 5004;
	const ERROR_QUOTA_EXCEEDED = 5005;
	const ERROR_API_ERROR = 5006;
	const ERROR_INVALID_RANGE = 5007;
	const ERROR_SHEET_CREATION_FAILED = 5008;

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

			case self::ERROR_INVALID_CREDENTIALS:
				return __( 'Invalid Google Sheets credentials.', 'shop-explorer' );

			case self::ERROR_SHEET_NOT_FOUND:
				return __( 'Google Sheet not found.', 'shop-explorer' );

			case self::ERROR_PERMISSION_DENIED:
				return __( 'Permission denied to access Google Sheet.', 'shop-explorer' );

			case self::ERROR_QUOTA_EXCEEDED:
				return __( 'Google Sheets API quota exceeded.', 'shop-explorer' );

			case self::ERROR_API_ERROR:
				return __( 'Google Sheets API error occurred.', 'shop-explorer' );

			case self::ERROR_INVALID_RANGE:
				return __( 'Invalid Google Sheets range specified.', 'shop-explorer' );

			case self::ERROR_SHEET_CREATION_FAILED:
				return __( 'Failed to create Google Sheet.', 'shop-explorer' );

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