Skip to main content

h3o_ice/
error.rs

1use std::{error::Error, fmt};
2
3/// Errors occurring while building a set or a map.
4#[derive(Debug)]
5#[non_exhaustive]
6pub enum BuildError {
7    /// Failed to build the underlying FST.
8    Fst(fst::Error),
9}
10
11impl fmt::Display for BuildError {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match *self {
14            Self::Fst(ref err) => write!(f, "FST error: {err}"),
15        }
16    }
17}
18
19impl Error for BuildError {
20    fn source(&self) -> Option<&(dyn Error + 'static)> {
21        match *self {
22            Self::Fst(ref err) => Some(err),
23        }
24    }
25}
26
27impl From<fst::Error> for BuildError {
28    fn from(err: fst::Error) -> Self {
29        Self::Fst(err)
30    }
31}