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.
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
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
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
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
impl Error
Sourcepub fn invalid(message: impl Into<String>) -> Self
pub fn invalid(message: impl Into<String>) -> Self
An Invalid error with no attributable field.
Sourcepub fn invalid_field(
field: impl Into<String>,
message: impl Into<String>,
) -> Self
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).
Sourcepub fn data_layer(message: impl Into<String>) -> Self
pub fn data_layer(message: impl Into<String>) -> Self
A DataLayer error with no captured cause.
Sourcepub fn data_layer_from(
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
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 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()