1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq)]
7pub enum SynapseError {
8 MissingField(&'static str),
10 InvalidValue {
12 field: &'static str,
14 reason: &'static str,
16 },
17}
18
19impl fmt::Display for SynapseError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Self::MissingField(field) => write!(f, "missing required field: {field}"),
23 Self::InvalidValue { field, reason } => {
24 write!(f, "invalid value for {field}: {reason}")
25 }
26 }
27 }
28}
29
30impl std::error::Error for SynapseError {}
31
32pub type Result<T> = std::result::Result<T, SynapseError>;