pub enum DomainError {
Show 15 variants
LifecycleRefused {
operation: &'static str,
phase: CeremonyLifecyclePhase,
},
EmptyField {
field: &'static str,
},
FieldTooLong {
field: &'static str,
actual: usize,
max: usize,
},
InvalidCharacters {
field: &'static str,
},
OutOfRange {
field: &'static str,
value: f64,
min: f64,
max: f64,
},
MustBeNonZero {
field: &'static str,
},
EmptyCollection {
field: &'static str,
},
InvalidTransition {
from: &'static str,
to: &'static str,
},
InvariantViolated {
reason: &'static str,
},
NotFound {
what: &'static str,
},
InvalidDocument {
reason: String,
},
AlreadyExists {
what: &'static str,
},
Conflict {
what: &'static str,
},
NoValidProposal {
contract_id: String,
},
UnreadableCeremonyEvent {
event_type: &'static str,
version: u32,
reason: &'static str,
},
}Expand description
All errors that the core domain can raise.
Variants are intentionally coarse-grained at the boundary: each variant names the invariant that was violated, not the primitive type involved.
Variants§
LifecycleRefused
EmptyField
A required textual field was empty or whitespace-only.
FieldTooLong
A textual field exceeded its maximum allowed length.
InvalidCharacters
A textual field contained characters outside the allowed set.
OutOfRange
A numeric value fell outside its allowed range.
MustBeNonZero
A numeric value that must be non-zero was zero.
EmptyCollection
A collection that must contain at least one element was empty.
InvalidTransition
A state transition was attempted from an invalid state.
InvariantViolated
An aggregate rejected a command because its preconditions were not met (e.g. registering an agent into a sealed council).
NotFound
A lookup in a domain registry did not resolve.
InvalidDocument
A document the caller authored describes something that cannot be built, and saying which part requires naming it.
Distinct from the field-level complaints above: those name one
field that is wrong on its own, and this one names parts that
are each acceptable and do not fit together — a stage owned by
nobody at the table, a name that collides with a generated one.
The reason is owned rather than &'static str because the
elements at fault carry the caller’s own names, and a defect
that cannot say which element it is about sends an author
looking through the whole document.
AlreadyExists
A domain entity with the same identity already exists.
Conflict
Somebody else changed this first.
A distinct variant rather than an invariant violation, because the two ask different things of a caller. An invariant that was violated will be violated again by the same call; a conflict is the expected outcome of two callers reaching the same thing at once, and the answer is to reload and decide, not to give up.
Collapsing them made a caller unable to tell “try again from what is stored now” from “this can never work”.
NoValidProposal
No candidate satisfied the structured output contract.
UnreadableCeremonyEvent
A sealed ceremony event could not be read back as the type and payload schema version its record names.
Names both so an operator can tell which record and which reader disagree: a version no reader exists for, a payload that is not an event, or a payload tagged as a different type.
Trait Implementations§
Source§impl Clone for DomainError
impl Clone for DomainError
Source§impl Debug for DomainError
impl Debug for DomainError
Source§impl Display for DomainError
impl Display for DomainError
Source§impl Error for DomainError
impl Error for DomainError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()