Skip to main content

lxdb_format/
error.rs

1use std::{error::Error, fmt};
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub enum FormatError {
5    UnexpectedRecordSize { record: &'static str, expected: usize, found: usize },
6    InvalidHeader,
7}
8
9impl fmt::Display for FormatError {
10    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
11        match self {
12            Self::UnexpectedRecordSize { record, expected, found } => {
13                write!(formatter, "invalid {record} size: expected {expected} bytes, found {found}",)
14            }
15            Self::InvalidHeader => {
16                write!(formatter, "invalid or unsupported LXDB header")
17            }
18        }
19    }
20}
21
22impl Error for FormatError {}