castep_cell_io/parsing/error/
mod.rs1use std::fmt::Display;
2
3#[derive(Debug)]
4pub enum CellParseError {
5 FileReadingFailure,
6 UnexpectedLength,
7 UnexpectedValueType,
8 Invalid,
9 GetBlockDataFailure,
10 GetFieldDataFailure,
11 RequiredSectionMissing,
12}
13
14impl Display for CellParseError {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 match self {
17 Self::UnexpectedLength => f.write_str("Unexpected length of data"),
18 Self::UnexpectedValueType => f.write_str("Unexpected value type"),
19 Self::Invalid => f.write_str("Not valid keywords or data in `.cell`"),
20 Self::GetBlockDataFailure => f.write_str("Fail to get block data"),
21 Self::GetFieldDataFailure => f.write_str("Fail to get field data"),
22 Self::RequiredSectionMissing => {
23 f.write_str("Missing lattice parameters and/or ionic positions!")
24 }
25 Self::FileReadingFailure => f.write_str("Failed to read from file"),
26 }
27 }
28}
29
30impl std::error::Error for CellParseError {}