Skip to main content

lex_babel/
error.rs

1//! Error types for format operations
2
3use std::fmt;
4
5/// Errors that can occur during format operations
6#[derive(Debug, Clone, PartialEq)]
7pub enum FormatError {
8    /// Format not found in registry
9    FormatNotFound(String),
10    /// Error during parsing
11    ParseError(String),
12    /// Error during serialization
13    SerializationError(String),
14    /// Format does not support parsing
15    NotSupported(String),
16}
17
18impl fmt::Display for FormatError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            FormatError::FormatNotFound(name) => write!(f, "Format '{name}' not found"),
22            FormatError::ParseError(msg) => write!(f, "Parse error: {msg}"),
23            FormatError::SerializationError(msg) => write!(f, "Serialization error: {msg}"),
24            FormatError::NotSupported(msg) => write!(f, "Operation not supported: {msg}"),
25        }
26    }
27}
28
29impl std::error::Error for FormatError {}