Skip to main content

altium_format/
error.rs

1//! Error types for the Altium library.
2
3use thiserror::Error;
4
5/// Main error type for Altium file operations.
6#[derive(Error, Debug)]
7pub enum AltiumError {
8    /// I/O error when reading/writing files.
9    #[error("I/O error: {0}")]
10    Io(#[from] std::io::Error),
11
12    /// Invalid parameter format.
13    #[error("Invalid parameter format: {0}")]
14    InvalidParameter(String),
15
16    /// Invalid coordinate format.
17    #[error("Invalid coordinate format: {0}")]
18    InvalidCoordinate(String),
19
20    /// Invalid unit format.
21    #[error("Invalid unit: {0}")]
22    InvalidUnit(String),
23
24    /// Invalid layer.
25    #[error("Invalid layer: {0}")]
26    InvalidLayer(String),
27
28    /// Invalid record type.
29    #[error("Invalid record type: {0}")]
30    InvalidRecord(String),
31
32    /// Missing required data.
33    #[error("Missing required data: {0}")]
34    MissingData(String),
35
36    /// Decompression error (zlib).
37    #[error("Decompression error: {0}")]
38    Decompression(String),
39
40    /// Encoding error (Windows-1252 or UTF-8).
41    #[error("Encoding error: {0}")]
42    Encoding(String),
43
44    /// Unexpected end of stream.
45    #[error("Unexpected end of stream")]
46    UnexpectedEof,
47
48    /// Generic parse error.
49    #[error("Parse error: {0}")]
50    Parse(String),
51
52    /// Validation error for invalid data values.
53    #[error("Validation error: {0}")]
54    Validation(String),
55}
56
57/// Result type alias for Altium operations.
58pub type Result<T> = std::result::Result<T, AltiumError>;