<?php

declare(strict_types=1);

namespace App\Domain\Git\Exceptions;

use App\Domain\Sysapi\Contracts\SysapiResult;
use RuntimeException;

class GitException extends RuntimeException
{
    public function __construct(string $message, public readonly ?SysapiResult $sysapiResult = null)
    {
        parent::__construct($message);
    }

    public static function invalidInput(string $reason): self
    {
        return new self("Geçersiz git girdi: {$reason}");
    }

    public static function notFound(int $id): self
    {
        return new self("Git repo bulunamadı (id={$id})");
    }

    public static function sysapiFailed(string $op, SysapiResult $r): self
    {
        return new self("Git {$op} başarısız (exit {$r->exitCode}): {$r->stderr}", $r);
    }
}
