<?php

declare(strict_types=1);

namespace App\ApiClient;

use RuntimeException;

/**
 * Base for everything the ApiClient throws. Controllers catch these
 * concretely (`ApiAuthException`, `ApiValidationException`, …) rather
 * than the bare `\RuntimeException` so the rendering layer can pick a
 * sensible response per case.
 */
class ApiException extends RuntimeException
{
    public function __construct(
        string $message,
        public readonly int $statusCode = 0,
        public readonly ?string $apiError = null,
        ?\Throwable $previous = null,
    ) {
        parent::__construct($message, 0, $previous);
    }
}
