rusty_schema_diff/error.rs
1//! Error types for schema analysis operations
2//!
3//! This module provides custom error types and a Result type alias for the library.
4
5use thiserror::Error;
6
7/// Represents errors that can occur during schema analysis operations
8///
9/// This enum covers various error cases that might occur during schema parsing,
10/// comparison, and validation operations.
11#[derive(Error, Debug)]
12pub enum SchemaDiffError {
13 /// Error that occurs during schema parsing
14 #[error("Failed to parse schema: {0}")]
15 ParseError(String),
16
17 /// Error that occurs during schema comparison
18 #[error("Schema comparison failed: {0}")]
19 ComparisonError(String),
20
21 /// Error that occurs when an invalid schema format is provided
22 #[error("Invalid schema format: {0}")]
23 InvalidFormat(String),
24
25 /// Error that occurs during file I/O operations
26 #[error("IO error: {0}")]
27 IoError(#[from] std::io::Error),
28
29 /// Error that occurs during JSON parsing
30 #[error("JSON error: {0}")]
31 JsonError(#[from] serde_json::Error),
32
33 /// Error that occurs during Protobuf operations
34 #[error("Protobuf error: {0}")]
35 ProtobufError(String),
36}
37
38/// A specialized Result type for schema analysis operations
39///
40/// This type alias helps simplify error handling throughout the library.
41pub type Result<T> = std::result::Result<T, SchemaDiffError>;