use thiserror::Error;
#[derive(Debug, Clone, Copy, PartialEq, Error)]
pub enum UnitError {
#[error("state of charge out of range: {0}")]
SocOutOfRange(f64),
}
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum IdError {
#[error("identifier must not be empty")]
Empty,
#[error("identifier is longer than 64 characters: {0} characters")]
TooLong(usize),
#[error("identifier contains an unsupported character {0:?}; allowed: a-z, 0-9, '.', '_', '-'")]
BadCharacter(char),
}
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum SiteError {
#[error("duplicate {kind} identifier: {id}")]
DuplicateId {
kind: &'static str,
id: String,
},
#[error("asset {asset} is on unknown circuit {circuit}")]
UnknownCircuit {
asset: String,
circuit: String,
},
#[error("circuit {circuit} has unknown parent {parent}")]
UnknownParent {
circuit: String,
parent: String,
},
#[error("circuit hierarchy contains a cycle through {circuit}")]
CircuitCycle {
circuit: String,
},
}
#[derive(Debug, Clone, PartialEq, Error)]
pub enum SetpointError {
#[error("setpoint for {asset} is not a finite value")]
NotFinite {
asset: String,
},
}