<?php

declare(strict_types=1);

namespace ApiModel\Shared\Exceptions;

use RuntimeException;

class ApiException extends RuntimeException
{
    /** @param array<string, mixed>|null $details */
    public function __construct(
        string $message = '',
        int $httpStatus = 400,
        private readonly string $errorCode = 'API_ERROR',
        private readonly ?array $details = null,
    ) {
        parent::__construct($message, $httpStatus);
    }

    public function getErrorCode(): string
    {
        return $this->errorCode;
    }

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