// Generated by alef. Do not edit by hand.
@file:Suppress(
    "ktlint:standard:trailing-comma-on-call-site",
    "ktlint:standard:trailing-comma-on-declaration-site",
    "ktlint:standard:spacing-between-declarations-with-comments",
    "ktlint:standard:spacing-between-declarations-with-annotations",
    "ktlint:standard:when-entry-bracing",
    "ktlint:standard:blank-line-between-when-conditions",
    "ktlint:standard:blank-line-before-declaration",
    "ktlint:standard:chain-method-continuation",
    "ktlint:standard:annotation",
    "ktlint:standard:max-line-length",
    "ktlint:standard:no-semi",
    "ktlint:standard:statement-wrapping",
    "MaxLineLength",
    "TooManyFunctions",
    "FunctionParameterNaming",
    "LongParameterList",
    "CyclomaticComplexMethod",
    "LongMethod",
)

package dev.kreuzberg

/**
 * Main error type for all Kreuzberg operations.
 *
 * All errors in Kreuzberg use this enum, which preserves error chains
 * and provides context for debugging.
 *
 * # Variants
 *
 * - `Io` - File system and I/O errors (always bubble up)
 * - `Parsing` - Document parsing errors (corrupt files, unsupported features)
 * - `Ocr` - OCR processing errors
 * - `Validation` - Input validation errors (invalid paths, config, parameters)
 * - `Cache` - Cache operation errors (non-fatal, can be ignored)
 * - `ImageProcessing` - Image manipulation errors
 * - `Serialization` - JSON/MessagePack serialization errors
 * - `MissingDependency` - Missing optional dependencies (tesseract, etc.)
 * - `Plugin` - Plugin-specific errors
 * - `LockPoisoned` - Mutex/RwLock poisoning (should not happen in normal operation)
 * - `UnsupportedFormat` - Unsupported MIME type or file format
 * - `Other` - Catch-all for uncommon errors
 */
sealed class KreuzbergError(message: String) : Exception(message) {
    data class Io(val field0: String) : KreuzbergError("IO error: $field0")
    data class Parsing(override val message: String) : KreuzbergError("Parsing error: {message}")
    data class Ocr(override val message: String) : KreuzbergError("OCR error: {message}")
    data class Validation(
        override val message: String,
    ) : KreuzbergError("Validation error: {message}")
    data class Cache(override val message: String) : KreuzbergError("Cache error: {message}")
    data class ImageProcessing(
        override val message: String,
    ) : KreuzbergError("Image processing error: {message}")
    data class Serialization(
        override val message: String,
    ) : KreuzbergError("Serialization error: {message}")
    data class MissingDependency(val field0: String) : KreuzbergError("Missing dependency: $field0")
    data class Plugin(
        override val message: String,
        val pluginName: String,
    ) : KreuzbergError("Plugin error in '{plugin_name}': {message}")
    data class LockPoisoned(val field0: String) : KreuzbergError("Lock poisoned: $field0")
    data class UnsupportedFormat(val field0: String) : KreuzbergError("Unsupported format: $field0")
    data class Embedding(
        override val message: String,
    ) : KreuzbergError("Embedding error: {message}")
    data class Timeout(
        val elapsedMs: Long,
        val limitMs: Long,
    ) : KreuzbergError("Extraction timed out after {elapsed_ms}ms (limit: {limit_ms}ms)")
    object Cancelled : KreuzbergError("Extraction cancelled")
    data class Security(
        override val message: String,
    ) : KreuzbergError("Security violation: {message}")
    data class Other(val field0: String) : KreuzbergError("$field0")
}
