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

namespace SHOPEXPLORER\Exceptions;

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

/**
 * Configuration exception class
 *
 * @since 1.0.0
 */
class SHOPEX_ConfigurationException extends SHOPEX_ShopExplorerException {

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

	/**
	 * Configuration error codes
	 */
	const ERROR_INVALID_SETTING = 3001;
	const ERROR_MISSING_REQUIRED = 3002;
	const ERROR_VALIDATION_FAILED = 3003;
	const ERROR_SAVE_FAILED = 3004;
	const ERROR_LOAD_FAILED = 3005;
	const ERROR_INCOMPATIBLE_MODE = 3006;

	/**
	 * Get user-friendly error message
	 *
	 * @return string
	 */
	public function get_user_message() {
		switch ( $this->getCode() ) {
			case self::ERROR_INVALID_SETTING:
				return __( 'Invalid configuration setting provided.', 'shop-explorer' );

			case self::ERROR_MISSING_REQUIRED:
				return __( 'Required configuration setting is missing.', 'shop-explorer' );

			case self::ERROR_VALIDATION_FAILED:
				return __( 'Configuration validation failed.', 'shop-explorer' );

			case self::ERROR_SAVE_FAILED:
				return __( 'Failed to save configuration settings.', 'shop-explorer' );

			case self::ERROR_LOAD_FAILED:
				return __( 'Failed to load configuration settings.', 'shop-explorer' );

			case self::ERROR_INCOMPATIBLE_MODE:
				return __( 'Incompatible mode configuration detected.', 'shop-explorer' );

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