#[non_exhaustive]pub enum Error {
Rejected(Rejection),
BatchRejected {
index: usize,
rejection: Rejection,
},
Value(ValueError),
Amount(AmountError),
Query(QueryError),
Transparency(Error),
Integrity(IntegrityError),
Backend(BackendError),
Config(ConfigError),
}Expand description
Everything a ledger operation can fail with.
use doubleentry::{Error, Rejection};
let error = Error::from(Rejection::TooFewPostings { count: 1 });
assert_eq!(error.rejection().map(Rejection::code), Some(101));
assert!(!error.is_transient());
assert_eq!(error.to_string(), "rejected: [101] an entry needs at least two postings, found 1");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Rejected(Rejection)
The ledger refused the input. Final for this input: do not retry it unchanged.
BatchRejected
The ledger refused draft index of an atomic batch
(Journal::record_batch); nothing of
the batch was recorded. Final for this batch: do not retry it
unchanged.
Value(ValueError)
A standalone value constructor failed. Never returned by a ledger
operation: a malformed draft is Error::Rejected.
Amount(AmountError)
Money parsing or arithmetic failed. Never returned by a ledger operation.
Query(QueryError)
A read asked an impossible question.
Transparency(Error)
A transparency artefact — a note, checkpoint, cosignature, policy, proof, bundle or verifier step — was refused. Final for this input.
Integrity(IntegrityError)
The ledger’s own stored data fails verification. Never retry; investigate.
Backend(BackendError)
The backend failed. See is_transient and
may_have_applied.
Config(ConfigError)
The store holds another ledger, this ledger at another scale, or a
database of another schema: a configuration mistake (a wrong URL,
schema name, ledger id or P), not damaged data. Nothing was read or
changed; fix the configuration.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Whether retrying the same operation may succeed: only a transient backend failure.
Sourcepub fn may_have_applied(&self) -> bool
pub fn may_have_applied(&self) -> bool
Whether the operation may have been applied although it failed: only a backend failure whose outcome is unknown. Retry with the same draft — idempotency makes the retry safe.
Sourcepub fn code(&self) -> Option<u16>
pub fn code(&self) -> Option<u16>
The stable rejection code, when the ledger refused the input — the number an HTTP handler or a log line keys on.
use doubleentry::{Error, Rejection};
let error = Error::from(Rejection::TooFewPostings { count: 1 });
assert_eq!(error.code(), Some(101));
assert_eq!(format!("{error:?}"), "rejected: [101] an entry needs at least two postings, found 1");Trait Implementations§
Source§impl Debug for Error
The same line as Display — rejected: [427] … — so a main returning
this error prints its code and message; {:#?} shows the structure.
impl Debug for Error
The same line as Display — rejected: [427] … — so a main returning
this error prints its code and message; {:#?} shows the structure.
Source§impl Display for Error
One line — rejected: …, query: …, integrity failure at position 7: … — honouring width, fill and alignment and never cut short.
impl Display for Error
One line — rejected: …, query: …, integrity failure at position 7: … — honouring width, fill and alignment and never cut short.
Source§impl Error for Error
impl Error for Error
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()
Source§impl From<AmountError> for Error
impl From<AmountError> for Error
Source§fn from(error: AmountError) -> Self
fn from(error: AmountError) -> Self
Source§impl From<AuditFailure> for Error
impl From<AuditFailure> for Error
Source§fn from(failure: AuditFailure) -> Self
fn from(failure: AuditFailure) -> Self
Source§impl From<BackendError> for Error
impl From<BackendError> for Error
Source§fn from(error: BackendError) -> Self
fn from(error: BackendError) -> Self
Source§impl From<BuildError> for Error
impl From<BuildError> for Error
Source§fn from(error: BuildError) -> Self
fn from(error: BuildError) -> Self
The stage-1 Rejection a draft with this deferred error gets from
record.
Source§impl From<ConfigError> for Error
impl From<ConfigError> for Error
Source§fn from(error: ConfigError) -> Self
fn from(error: ConfigError) -> Self
Source§impl From<DecodeError> for Error
impl From<DecodeError> for Error
Source§fn from(error: DecodeError) -> Self
fn from(error: DecodeError) -> Self
Proven bytes that do not decode: transparency::Error::Decode.
Source§impl From<IntegrityError> for Error
impl From<IntegrityError> for Error
Source§fn from(error: IntegrityError) -> Self
fn from(error: IntegrityError) -> Self
Source§impl From<ProofError> for Error
impl From<ProofError> for Error
Source§fn from(error: ProofError) -> Self
fn from(error: ProofError) -> Self
A proof that does not verify: transparency::Error::Proof.
Source§impl From<QueryError> for Error
impl From<QueryError> for Error
Source§fn from(error: QueryError) -> Self
fn from(error: QueryError) -> Self
Source§impl From<SealOrderError> for Error
impl From<SealOrderError> for Error
Source§fn from(error: SealOrderError) -> Self
fn from(error: SealOrderError) -> Self
A seal that does not follow its predecessor:
transparency::Error::SealOrder.
Source§impl From<StoreError> for Error
impl From<StoreError> for Error
Source§fn from(error: StoreError) -> Self
fn from(error: StoreError) -> Self
Integrity is stored data the ledger cannot trust
(Error::Integrity); SchemaMismatch and LedgerMismatch are a
store configured for something else (Error::Config); everything
else is a BackendError keeping both flags, with the store error as
its source.
Source§impl From<ValueError> for Error
impl From<ValueError> for Error
Source§fn from(error: ValueError) -> Self
fn from(error: ValueError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more