use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Error)]
pub enum DomainError {
#[error("field `{field}` must not be empty")]
EmptyField { field: &'static str },
#[error("field `{field}` exceeds maximum length: {actual} > {max}")]
FieldTooLong {
field: &'static str,
actual: usize,
max: usize,
},
#[error("field `{field}` contains invalid characters")]
InvalidCharacters { field: &'static str },
#[error("value `{field}` out of range: {value} not in [{min}, {max}]")]
OutOfRange {
field: &'static str,
value: f64,
min: f64,
max: f64,
},
#[error("value `{field}` must be non-zero")]
MustBeNonZero { field: &'static str },
#[error("collection `{field}` must contain at least one element")]
EmptyCollection { field: &'static str },
#[error("invalid state transition `{from}` -> `{to}`")]
InvalidTransition {
from: &'static str,
to: &'static str,
},
#[error("invariant violated: {reason}")]
InvariantViolated { reason: &'static str },
#[error("not found: {what}")]
NotFound { what: &'static str },
#[error("{reason}")]
InvalidDocument { reason: String },
#[error("already exists: {what}")]
AlreadyExists { what: &'static str },
#[error("conflict: {what} was changed by someone else first")]
Conflict { what: &'static str },
#[error("no valid proposal satisfied output contract `{contract_id}`")]
NoValidProposal { contract_id: String },
#[error("ceremony event `{event_type}` at schema version {version} cannot be read: {reason}")]
UnreadableCeremonyEvent {
event_type: &'static str,
version: u32,
reason: &'static str,
},
}