1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::fmt::Display;

#[derive(Debug)]
pub enum CellParseError {
    UnexpectedLength,
    UnexpectedValueType,
    Invalid,
    GetBlockDataFailure,
    GetFieldDataFailure,
    RequiredSectionMissing,
}

impl Display for CellParseError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::UnexpectedLength => f.write_str("Unexpected length of data"),
            Self::UnexpectedValueType => f.write_str("Unexpected value type"),
            Self::Invalid => f.write_str("Not valid keywords or data in `.cell`"),
            Self::GetBlockDataFailure => f.write_str("Fail to get block data"),
            Self::GetFieldDataFailure => f.write_str("Fail to get field data"),
            Self::RequiredSectionMissing => {
                f.write_str("Missing lattice parameters and/or ionic positions!")
            }
        }
    }
}

impl std::error::Error for CellParseError {}