pub fn server_fail_value_from_backend<E: Display + ?Sized>(_err: &E) -> ValueExpand description
Construct the per-id serverFail Value used inside the
notCreated/notUpdated/notDestroyed maps of /set responses
(bd:JMAP-ic0j.68), without echoing the backend error’s
Display output onto the wire.
This is the Value-shaped sibling of server_fail_from_backend.
The handler-layer helper returns a JmapError which is only useful
where the entire method invocation fails. Per-id /set failures are
expressed as a serde_json::Value keyed under each failing id in
notCreated / notUpdated / notDestroyed; the existing
JmapError-shaped helper does not fit those sites, so each crate
previously hand-rolled
json!({ "type": "serverFail", "description": e.to_string() }) —
every one of which leaks the backend error’s Display onto the wire,
in direct violation of the JmapBackend::Error
Display MUST-NOT contract.
The err parameter is intentionally discarded (bd:JMAP-jfia.22),
matching the contract on server_fail_from_backend. It exists only
to keep the call site ergonomic — the function never reads it, logs
it, or stashes it. Callers that want their backend error visible in
operator logs MUST log it explicitly at the call site before invoking
this helper.
The function is generic over any Display so it
applies uniformly to JmapBackend::Error,
BackendSetError::Other,
BackendChangesError::Other, and any
extension-trait-specific error envelope. It also accepts the
&String shape produced by some legacy helpers that flattened a
backend error to String before propagating.
§Use at every per-id /set serverFail site
Replace:
json!({ "type": "serverFail", "description": e.to_string() })with:
server_fail_value_from_backend(&e)