package de.gecheckt.pdf.umbenenner.application.port.out;

/**
 * Unchecked exception thrown by persistence write operations when a technical
 * infrastructure failure prevents the operation from completing.
 * <p>
 * This exception is thrown by {@link DocumentRecordRepository} and
 * {@link ProcessingAttemptRepository} write methods, and by
 * {@link PersistenceSchemaInitializationPort#initializeSchema()}, when the underlying
 * persistence layer (SQLite) cannot be reached or returns an unrecoverable error.
 * <p>
 * <strong>Batch run impact:</strong>
 * <ul>
 *   <li>If thrown during <em>schema initialisation</em> at startup, the run must abort
 *       with exit code&nbsp;1.</li>
 *   <li>If thrown during <em>per-document write operations</em>, the current candidate
 *       is treated as a transient failure; the batch run continues with the remaining
 *       candidates.</li>
 * </ul>
 * <p>
 * The exception is <em>not</em> used for read operations; read failures are modelled
 * as {@link PersistenceLookupTechnicalFailure} in the sealed
 * {@link DocumentRecordLookupResult} hierarchy to allow exhaustive pattern matching
 * at the call site.
 *
 */
public class DocumentPersistenceException extends RuntimeException {

    private static final long serialVersionUID = -8362115097253107643L;

	/**
     * Constructs a new {@code DocumentPersistenceException} with the given message.
     *
     * @param message human-readable description of the persistence failure
     */
    public DocumentPersistenceException(String message) {
        super(message);
    }

    /**
     * Constructs a new {@code DocumentPersistenceException} with message and cause.
     *
     * @param message human-readable description of the persistence failure
     * @param cause   the underlying throwable that caused this failure
     */
    public DocumentPersistenceException(String message, Throwable cause) {
        super(message, cause);
    }
}
