csdif-core 0.1.3

Core library for modeling, validating, and transforming CSDIF data
Documentation
// SPDX-License-Identifier: MIT
// Copyright (c) 2025 Egon Kastelijn
// file: src/error.rs

//! Custom error type for CSDIF core operations.

use std::fmt;

/// Represents errors that can occur during CSDIF processing.
#[derive(Debug, Clone)]
pub enum CsdifError {
    /// Structural validation failed.
    Validation(String),

    /// Transformation failed due to missing or invalid input.
    Transformation(String),

    /// Generic error with a message.
    Other(String),
}

impl fmt::Display for CsdifError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            CsdifError::Validation(msg) => write!(f, "Validation error: {}", msg),
            CsdifError::Transformation(msg) => write!(f, "Transformation error: {}", msg),
            CsdifError::Other(msg) => write!(f, "Error: {}", msg),
        }
    }
}

#[derive(Debug)]
pub struct MappingError {
    pub message: String,
}

#[derive(Debug)]
pub enum ContextError {
    NotFound,
    InvalidFormat,
}