use thiserror::Error;
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum SnowflakeError {
#[error(
"bit fields must sum to exactly 63, \
got timestamp({t}) + machine_id({m}) + node_id({n}) + sequence({s}) = {total}"
)]
InvalidBitLayout {
t: u8,
m: u8,
n: u8,
s: u8,
total: u8,
},
#[error("machine_id {given} exceeds maximum {max} for the configured bit width")]
MachineIdOutOfRange { given: i32, max: i32 },
#[error("node_id {given} exceeds maximum {max} for the configured bit width")]
NodeIdOutOfRange { given: i32, max: i32 },
#[error("system clock moved backwards; cannot guarantee monotonic IDs")]
ClockMovedBackwards,
#[error("system clock error: time is before the configured epoch")]
ClockBeforeEpoch,
}