Skip to main content

mdmodels_core/
error.rs

1//! Error types for the mdmodels crate.
2//!
3//! This module defines the error types used throughout the crate,
4//! particularly for operations related to data model processing.
5
6use thiserror::Error;
7
8use crate::prelude::Validator;
9
10/// Errors that can occur when working with data models.
11///
12/// This enum represents the various error conditions that may arise
13/// during data model operations such as validation, deserialization,
14/// and file I/O.
15#[derive(Debug, Error)]
16pub enum DataModelError {
17    /// Error that occurs when a data model fails validation.
18    ///
19    /// Contains the validator with detailed validation errors.
20    #[error("Validation error: {0}")]
21    ValidationError(Validator),
22
23    /// Error that occurs when deserializing JSON data.
24    ///
25    /// This typically happens when parsing JSON schemas or model data.
26    #[error("Deserialize error: {0}")]
27    DeserializeError(#[from] serde_json::Error),
28
29    /// Error that occurs when reading files.
30    ///
31    /// This can happen when attempting to read model files from disk.
32    #[error("Read error: {0}")]
33    ReadError(#[from] std::io::Error),
34}