pub fn error_from(err: &Error, ctx: &Context) -> JsonApiErrorAvailable 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::Error | Status |
|---|---|
NotFound | 404 |
Forbidden | 403 |
PolicyError | 503 — an authorization outage, so retriable |
MissingTenant | 400 |
Invalid | 422, with source.pointer at the named field |
Conflict | 409 |
Contention | 503 |
Closing | 503 |
Unsupported | 501 |
UnknownResource, UnknownAction | 500 — a wiring bug |
DataLayer, Serialization | 500, 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.