Skip to main content

EngineError

Enum EngineError 

Source
#[non_exhaustive]
pub enum EngineError {
Show 17 variants Store { message: String, transient: bool, }, VersionConflict { expected: u64, actual: u64, }, Deserialization(String), Serialization(String), Snapshot { message: String, transient: bool, }, Outbox { message: String, transient: bool, }, Deadline { message: String, transient: bool, }, Registry { message: String, transient: bool, }, Inbox { message: String, transient: bool, }, Partner { message: String, transient: bool, }, DeadLetter { message: String, transient: bool, }, Workflow(WorkflowError), StreamQuotaExceeded { stream_id: StreamId, limit: u64, new_events: usize, actual: u64, }, Transport { endpoint: Box<str>, message: String, }, PartnerUnknown { recipient: Box<str>, }, RendererNotImplemented { message_type: Box<str>, message_id: Box<str>, }, InvalidStreamId { input: Box<str>, reason: &'static str, },
}
Expand description

Errors that can occur during engine operations (command dispatch, event persistence, state reconstruction).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Store

The event store returned an error.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

VersionConflict

Optimistic concurrency check failed: the stream was modified by a concurrent writer between the read and the append.

Fields

§expected: u64

The sequence number the caller expected the stream to be at.

§actual: u64

The actual current sequence number of the stream.

§

Deserialization(String)

Could not deserialize a stored event payload into the typed event.

This typically indicates a schema migration is required.

§

Serialization(String)

Could not serialize a domain event into the envelope payload.

§

Snapshot

A snapshot storage operation failed.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

Outbox

An outbox storage operation failed.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

Deadline

A deadline storage operation failed.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

Registry

A process registry operation failed.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

Inbox

An inbox (AS4 dedup) operation failed.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

Partner

A partner-store operation failed, or a required partner record is absent.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

DeadLetter

A dead-letter query operation failed.

Covers SlateDbDeadLetterSink::list_recent and similar read-path operations. Writes are fire-and-forget (logged on error) and do not produce this variant.

Fields

§message: String

Human-readable description of the storage failure.

§transient: bool

true when the error is transient (retry may succeed after backoff).

§

Workflow(WorkflowError)

The workflow rejected the command or reached an invalid state.

§

StreamQuotaExceeded

Appending the requested events would exceed the per-stream event count limit configured on the store.

This is a hard safety guard against runaway streams. The caller should archive or compact the stream before retrying.

The stream_id, limit, new_events, and actual fields are available for internal structured logging but are intentionally not included in the Display string returned to API callers to avoid leaking internal stream topology.

Fields

§stream_id: StreamId

The stream that hit the limit (for internal logging only).

§limit: u64

The configured maximum number of events per stream.

§new_events: usize

Number of events that would be written by this append.

§actual: u64

Total event count after the append would complete.

§

Transport

An AS4 transport send operation failed.

Distinct from Store so the outbox worker can decide retry strategy without string-matching: transport errors are potentially transient; serialization errors are permanent.

Fields

§endpoint: Box<str>

The AS4 endpoint URL (or "unknown" when not available).

§message: String

The underlying error description.

§

PartnerUnknown

The outbound message cannot be delivered because no AS4 endpoint is registered for the recipient GLN.

This is a permanent failure: the operator must add the missing --as4-partner <GLN>=<URL> entry before delivery can succeed. The outbox worker should dead-letter immediately rather than retrying.

Fields

§recipient: Box<str>

The recipient GLN that has no registered endpoint.

§

RendererNotImplemented

The outbound message cannot be rendered to EDIFACT wire format because no renderer is implemented for its message type.

This is a permanent failure: retrying will never succeed until a wire-format renderer is implemented for the message type. The outbox worker should dead-letter the message immediately and alert the operator.

Use this instead of silently transmitting JSON blobs over AS4, which violates BDEW MaKo interoperability requirements.

Fields

§message_type: Box<str>

The EDIFACT message type string (e.g. "MSCONS", "INVOIC").

§message_id: Box<str>

The outbox message ID for correlation with the dead-letter store.

§

InvalidStreamId

A string could not be converted into a valid StreamId.

Stream IDs must be non-empty and must not contain NUL bytes. This error is produced by StreamId::try_new and the TryFrom impls. Use the typed constructors (StreamId::for_process, StreamId::for_partner) where possible to avoid constructing stream IDs from raw strings.

Fields

§input: Box<str>

The rejected input (truncated to 200 chars for log safety).

§reason: &'static str

Human-readable explanation of why the ID was rejected.

Implementations§

Source§

impl EngineError

Source

pub fn store(message: impl Into<String>) -> Self

Construct a permanent (non-retriable) event-store error.

Source

pub fn transient_store(message: impl Into<String>) -> Self

Construct a transient (retriable) event-store error.

Source

pub fn outbox(message: impl Into<String>) -> Self

Construct a permanent outbox-store error.

Source

pub fn transient_outbox(message: impl Into<String>) -> Self

Construct a transient outbox-store error.

Source

pub fn deadline(message: impl Into<String>) -> Self

Construct a permanent deadline-store error.

Source

pub fn transient_deadline(message: impl Into<String>) -> Self

Construct a transient deadline-store error.

Source

pub fn registry(message: impl Into<String>) -> Self

Construct a permanent process-registry error.

Source

pub fn transient_registry(message: impl Into<String>) -> Self

Construct a transient process-registry error.

Source

pub fn inbox(message: impl Into<String>) -> Self

Construct a permanent inbox-store error.

Source

pub fn transient_inbox(message: impl Into<String>) -> Self

Construct a transient inbox-store error.

Source

pub fn snapshot(message: impl Into<String>) -> Self

Construct a permanent snapshot-store error.

Source

pub fn transient_snapshot(message: impl Into<String>) -> Self

Construct a transient snapshot-store error.

Source

pub fn partner(message: impl Into<String>) -> Self

Construct a permanent partner-store error.

Source

pub fn transient_partner(message: impl Into<String>) -> Self

Construct a transient partner-store error.

Source

pub fn dead_letter(message: impl Into<String>) -> Self

Construct a permanent dead-letter-store error.

Source

pub fn transient_dead_letter(message: impl Into<String>) -> Self

Construct a transient dead-letter-store error.

Source

pub fn is_version_conflict(&self) -> bool

Return true when this is a EngineError::VersionConflict.

Useful for retry logic: on a version conflict the caller should reload state and re-issue the command.

Source

pub fn is_stream_quota_exceeded(&self) -> bool

Return true when this is a EngineError::StreamQuotaExceeded.

Source

pub fn is_workflow_error(&self) -> bool

Return true when this is a EngineError::Workflow.

Useful for distinguishing infrastructure failures (store errors) from domain rejections (the workflow refused the command).

Source

pub fn is_transient(&self) -> bool

Return true when the error is likely transient and the operation can be safely retried after a short backoff.

Storage errors carry an explicit transient flag set at the point of construction by the storage layer, eliminating any reliance on string-matching heuristics.

Transport errors (network timeouts, TLS failures) are always transient. All other errors (version conflicts, quota exceeded, workflow rejections, …) are permanent.

§Usage
for attempt in 0..MAX_RETRIES {
    match process.execute(cmd.clone()).await {
        Ok(result) => return Ok(result),
        Err(e) if e.is_version_conflict() => { /* reload and retry */ }
        Err(e) if e.is_transient() => {
            tokio::time::sleep(backoff(attempt)).await;
        }
        Err(e) => return Err(e),
    }
}
Source

pub fn is_partner_unknown(&self) -> bool

Return true when this is a EngineError::PartnerUnknown.

PartnerUnknown is a permanent failure: no retry will succeed until the operator registers the missing --as4-partner entry. The outbox worker should dead-letter the message immediately.

Source

pub fn is_renderer_not_implemented(&self) -> bool

Return true when this is a EngineError::RendererNotImplemented.

RendererNotImplemented is a permanent failure: no retry will succeed until a wire-format renderer is implemented for the message type. The outbox worker should dead-letter the message immediately.

Source

pub fn is_transport_error(&self) -> bool

Return true when this is a EngineError::Transport.

Source

pub fn as_workflow_error(&self) -> Option<&WorkflowError>

Return the inner WorkflowError if this is a workflow rejection, or None otherwise.

Source

pub fn is_snapshot_error(&self) -> bool

Return true when this is a EngineError::Snapshot.

Source

pub fn is_outbox_error(&self) -> bool

Return true when this is a EngineError::Outbox.

Source

pub fn is_deadline_error(&self) -> bool

Return true when this is a EngineError::Deadline.

Source

pub fn is_registry_error(&self) -> bool

Return true when this is a EngineError::Registry.

Source

pub fn is_inbox_error(&self) -> bool

Return true when this is a EngineError::Inbox.

Trait Implementations§

Source§

impl Debug for EngineError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for EngineError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for EngineError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<WorkflowError> for EngineError

Source§

fn from(source: WorkflowError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more