<?php

namespace AIPT\Api\Chatbot\Exceptions;

/**
 * Base exception class for chatbot errors.
 *
 * All chatbot-specific exceptions should extend this class
 * to enable catch-all handling when needed.
 *
 * @package AIPT\Api\Chatbot\Exceptions
 * @since 2.5.0
 */
class ChatbotException extends \Exception {

    /**
     * Error code for client response.
     *
     * @var string
     */
    protected $error_code = 'chatbot_error';

    /**
     * Whether this error is recoverable.
     *
     * @var bool
     */
    protected $recoverable = false;

    /**
     * HTTP status code to return.
     *
     * @var int
     */
    protected $http_status = 500;

    /**
     * Get the error code for client response.
     *
     * @return string
     */
    public function getErrorCode(): string {
        return $this->error_code;
    }

    /**
     * Check if error is recoverable (should retry).
     *
     * @return bool
     */
    public function isRecoverable(): bool {
        return $this->recoverable;
    }

    /**
     * Get HTTP status code.
     *
     * @return int
     */
    public function getHttpStatus(): int {
        return $this->http_status;
    }

    /**
     * Get user-friendly error message.
     *
     * @return string
     */
    public function getUserMessage(): string {
        return __('An error occurred. Please try again.', 'ai-product-tools');
    }
}
