flagsmith_flag_engine/
error.rs

1use std::fmt;
2
3/// Wraps several types of errors.
4#[derive(Debug)]
5pub struct Error {
6    pub kind: ErrorKind,
7}
8
9/// Defines error kind.
10#[derive(Debug, PartialEq)]
11pub enum ErrorKind {
12    FeatureStateNotFound,
13    DuplicateFeatureState,
14}
15
16impl Error {
17    pub fn new(kind: ErrorKind) -> Error {
18        Error { kind }
19    }
20}
21impl fmt::Display for Error {
22    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23        match self.kind {
24            ErrorKind::FeatureStateNotFound => write!(f, "Feature State Not Found"),
25            ErrorKind::DuplicateFeatureState => write!(f, "Feature State already exists"),
26        }
27    }
28}