<?php

namespace AIPT\Api\Chatbot\Exceptions;

/**
 * Exception for content filter/moderation errors.
 *
 * Thrown when AI provider blocks content due to policy violations.
 * This error is NOT recoverable with the same content.
 *
 * @package AIPT\Api\Chatbot\Exceptions
 * @since 2.5.0
 */
class ContentFilterException extends ChatbotException {

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

    /**
     * This error is not recoverable with the same content.
     *
     * @var bool
     */
    protected $recoverable = false;

    /**
     * HTTP status code.
     *
     * @var int
     */
    protected $http_status = 400;

    /**
     * Constructor.
     *
     * @param string          $message  Error message.
     * @param int             $code     Exception code.
     * @param \Throwable|null $previous Previous exception.
     */
    public function __construct(
        string $message = '',
        int $code = 0,
        ?\Throwable $previous = null
    ) {
        parent::__construct($message ?: __('Content was filtered by safety policies.', 'ai-product-tools'), $code, $previous);
    }

    /**
     * Get user-friendly error message.
     *
     * @return string
     */
    public function getUserMessage(): string {
        return __('Your message could not be processed. Please try asking in a different way.', 'ai-product-tools');
    }
}
