<?php
namespace EasyChat\Library\AiProvider;

class ProviderException extends \RuntimeException {
    private $providerCode;
    private $retryAfter;

    public function __construct($message, $providerCode = 'provider_error', $httpStatus = 0, $retryAfter = null) {
        parent::__construct((string)$message, (int)$httpStatus);
        $this->providerCode = (string)$providerCode;
        $this->retryAfter = $retryAfter !== null ? max(0, (int)$retryAfter) : null;
    }

    public function getProviderCode() {
        return $this->providerCode;
    }

    public function getHttpStatus() {
        return (int)$this->getCode();
    }

    public function getRetryAfter() {
        return $this->retryAfter;
    }
}
