Skip to main content

error_from

Function error_from 

Source
pub fn error_from(err: &Error, ctx: &Context) -> JsonApiError
Available on crate feature domain only.
Expand description

An ash-domain error, as a JSON:API error.

Most of what the domain returns is a legitimate outcome rather than a fault, and reporting all of it as 500 would tell a client to retry a request that will never succeed. The mapping:

ash_domain::ErrorStatus
NotFound404
Forbidden403
PolicyError503 — an authorization outage, so retriable
MissingTenant400
Invalid422, with source.pointer at the named field
Conflict409
Contention503
Closing503
Unsupported501
UnknownResource, UnknownAction500 — a wiring bug
DataLayer, Serialization500, message logged not sent

The two 500s stay opaque: a data-layer message can hold a connection string or a fragment of a query, so it is logged against the correlation id and never serialized.