<?php
/**
 * AI suggestion exception.
 *
 * @package Affilun\Application\Ai
 */

declare(strict_types=1);

namespace Affilun\Application\Ai;

use RuntimeException;

/**
 * Stable AI suggestion failure envelope.
 */
final class AiSuggestionException extends RuntimeException {

	/**
	 * @param string              $errorCode Stable error code.
	 * @param string              $message   Message.
	 * @param int                 $status    HTTP status.
	 * @param array<string,mixed> $details   Details.
	 * @param bool                $retryable Retryable.
	 */
	public function __construct(
		private string $errorCode,
		string $message,
		private int $status,
		private array $details = array(),
		private bool $retryable = false
	) {
		parent::__construct( $message );
	}

	/**
	 * Stable error code.
	 */
	public function errorCode(): string {
		return $this->errorCode;
	}

	/**
	 * HTTP status.
	 */
	public function status(): int {
		return $this->status;
	}

	/** @return array<string,mixed> */
	public function details(): array {
		return $this->details;
	}

	/**
	 * Whether retry may succeed.
	 */
	public function retryable(): bool {
		return $this->retryable;
	}
}
