<?php

/**
 * Thrown when a submission would create a thesis that is too similar to an
 * already-existing record.
 *
 * Carries enough information for the caller to build a useful warning message
 * with a link to the existing thesis.
 */
class DuplicateThesisException extends RuntimeException
{
    public function __construct(
        public readonly int    $existingThesisId,
        public readonly string $existingIdentifier,
        public readonly string $existingTitle,
        public readonly string $existingAuthor,
        public readonly int    $existingYear,
        string $message = ''
    ) {
        if ($message === '') {
            $message = "Un TFE similaire existe déjà ($existingIdentifier — $existingAuthor, $existingYear).";
        }
        parent::__construct($message);
    }
}
