csdif_core/
error.rs

1// SPDX-License-Identifier: MIT
2
3//! Custom error type for CSDIF core operations.
4
5use std::fmt;
6
7/// Represents errors that can occur during CSDIF processing.
8#[derive(Debug, Clone)]
9pub enum CsdifError {
10    /// Structural validation failed.
11    Validation(String),
12
13    /// Transformation failed due to missing or invalid input.
14    Transformation(String),
15
16    /// Generic error with a message.
17    Other(String),
18}
19
20impl fmt::Display for CsdifError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            CsdifError::Validation(msg) => write!(f, "Validation error: {}", msg),
24            CsdifError::Transformation(msg) => write!(f, "Transformation error: {}", msg),
25            CsdifError::Other(msg) => write!(f, "Error: {}", msg),
26        }
27    }
28}
29
30#[derive(Debug)]
31pub struct MappingError {
32    pub message: String,
33}
34
35#[derive(Debug)]
36pub enum ContextError {
37    NotFound,
38    InvalidFormat,
39}
40