pub enum DomainError {
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,
},
AlreadyExists {
what: &'static str,
},
Conflict {
what: &'static str,
},
NoValidProposal {
contract_id: String,
},
}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§
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.
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.
Trait Implementations§
Source§impl Clone for DomainError
impl Clone for DomainError
Source§fn clone(&self) -> DomainError
fn clone(&self) -> DomainError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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()