package de.gecheckt.pdf.umbenenner.domain.model;

import java.util.Objects;

/**
 * Represents a technical (infrastructure) failure during PDF text extraction.
 * <p>
 * This indicates that something went wrong with the extraction process itself,
 * such as file I/O errors, PDFBox library problems, or out-of-memory conditions.
 * <p>
 * These are typically retryable conditions in later batch runs, as they may be
 * transient infrastructure issues.
 *
 * @param errorMessage a description of what went wrong (non-null, non-empty)
 * @param cause the underlying exception, if any (may be null)
 */
public record PdfExtractionTechnicalError(
    String errorMessage,
    Throwable cause
) implements PdfExtractionResult {
    /**
     * Constructor with validation.
     *
     * @param errorMessage must be non-null and non-empty
     * @param cause may be null
     * @throws NullPointerException if errorMessage is null
     * @throws IllegalArgumentException if errorMessage is empty
     */
    public PdfExtractionTechnicalError {
        Objects.requireNonNull(errorMessage, "errorMessage must not be null");
        if (errorMessage.isEmpty()) {
            throw new IllegalArgumentException("errorMessage must not be empty");
        }
    }
}
