Skip to main content

Error

Enum Error 

Source
pub enum Error {
Show 13 variants UnknownResource(String), UnknownAction { resource: String, action: String, }, NotFound(String), Forbidden(String), PolicyError(String), MissingTenant(String), DataLayer { message: String, source: Option<Box<dyn Error + Send + Sync>>, }, Serialization(String), Invalid { field: Option<String>, message: String, }, Unsupported(String), Contention(String), Conflict { resource: String, message: String, }, Closing(String),
}
Expand description

Everything that can go wrong resolving, authorizing, or executing an action.

Variants§

§

UnknownResource(String)

No resource is registered under this name in the domain.

§

UnknownAction

The resource has no action with this name and the requested kind.

Fields

§resource: String

The resource queried.

§action: String

The action name that was not found.

§

NotFound(String)

A record was expected but not found.

§

Forbidden(String)

A Policy forbade the action.

§

PolicyError(String)

A policy could not reach a decision — typically an external PolicyClient backend failed or timed out (Decision::Error). Distinct from Forbidden: the action is aborted fail-closed, but this signals an authorization outage, not a deliberate denial, so a caller can retry or alert rather than treat it as “access denied”.

§

MissingTenant(String)

A tenant-scoped resource was accessed without a tenant set on the Context. Call set_tenant before the action.

§

DataLayer

The data layer failed (I/O, database, etc.). source, when present, is the underlying cause and participates in the std::error::Error chain (source() returns it), so a consumer can downcast to their storage error rather than parse a flattened string. Build it with Error::data_layer / Error::data_layer_from.

Fields

§message: String

Description of the failure.

§source: Option<Box<dyn Error + Send + Sync>>

The underlying cause, if the layer supplied one.

§

Serialization(String)

(De)serialization of a record failed.

§

Invalid

Invalid input or a violated domain invariant (also raised by extensions such as the state-machine guard). field names the offending attribute/path when the failure is attributable to one (e.g. "address.city"), else None, so a caller can branch on what was invalid instead of parsing the message. Build it with Error::invalid / Error::invalid_field.

Fields

§field: Option<String>

The attribute/path at fault, when the failure is attributable to one.

§message: String

Human-readable description of what was invalid.

§

Unsupported(String)

The operation is not supported by this backend — for a consumer data layer to signal an operation it does not implement (e.g. a transaction or batch method it chose not to support).

§

Contention(String)

A lock could not be acquired for a contended record — raised by the single-writer lock extension when ash-lock fails to grant the lease.

§

Conflict

An optimistic-concurrency conflict: the row was modified by someone else between the read and the write, so this update was refused rather than allowed to overwrite a change it never saw.

Raised only for a resource that declares a version_attribute. It is a legitimate control-flow outcome, not a fault — the correct response is to re-read the row, re-apply the change to the new state, and retry. Distinct from Contention, which means a lock could not be taken (the write never attempted); a Conflict means the write was attempted and lost the race.

Fields

§resource: String

The resource whose row was contended.

§message: String

What was expected versus what was found.

§

Closing(String)

The domain is shutting down and is no longer accepting new work — raised once Domain::begin_close / close has flipped the close gate. It is a lifecycle signal, not a fault: the action never ran and nothing was observed, so a caller draining its own work should stop, not retry. Like Forbidden it is a legitimate control-flow outcome — distinct from DataLayer / PolicyError, which signal a genuine fault.

Implementations§

Source§

impl Error

Source

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

An Invalid error with no attributable field.

Source

pub fn invalid_field( field: impl Into<String>, message: impl Into<String>, ) -> Self

An Invalid error attributed to field (an attribute name or dotted path).

Source

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

A DataLayer error with no captured cause.

Source

pub fn data_layer_from( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self

A DataLayer error wrapping its underlying source, which stays reachable through std::error::Error::source.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Forget for Error

§

impl Freeze for Error

§

impl Move for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.