gerber_types/
errors.rs

1//! Error types used in the gerber-types library.
2
3use std::io::Error as IoError;
4
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8pub enum GerberError {
9    #[error("Conversion between two types failed: {0}")]
10    ConversionError(String),
11
12    #[error("Bad coordinate format: {0}")]
13    CoordinateFormatError(String),
14
15    #[error("A value is out of range: {0}")]
16    RangeError(String),
17
18    #[error("Required data is missing: {0}")]
19    MissingDataError(String),
20
21    #[error("I/O error during code generation")]
22    IoError(#[from] IoError),
23}
24
25pub type GerberResult<T> = Result<T, GerberError>;
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30
31    #[test]
32    fn test_error_msg() {
33        let err = GerberError::CoordinateFormatError("Something went wrong".into());
34        assert_eq!(
35            err.to_string(),
36            "Bad coordinate format: Something went wrong"
37        );
38    }
39}