Skip to main content

csdif_core/
error.rs

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