<?php

declare(strict_types=1);

namespace App\Framework\DateTime\Exceptions;

use Exception;

class InvalidDateTimeException extends Exception
{
    public function __construct(string $dateTime, ?string $format = null, ?\Throwable $previous = null)
    {
        $message = $format !== null
            ? sprintf('Konnte DateTime nicht aus "%s" mit Format "%s" erstellen', $dateTime, $format)
            : sprintf('Ungültiges DateTime-Format: "%s"', $dateTime);

        parent::__construct($message, 0, $previous);
    }
}
