Skip to main content

server_fail_from_backend

Function server_fail_from_backend 

Source
pub fn server_fail_from_backend<E: Display + ?Sized>(_err: &E) -> JmapError
Expand description

Construct a JmapError::server_fail for a backend-originated error without echoing the backend error’s Display output onto the wire (bd:JMAP-wlip.2).

The err parameter is intentionally discarded (bd:JMAP-jfia.22). It exists only to keep the call site ergonomic (.map_err(|e| server_fail_from_backend(&e))) — 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; no logging happens here. The crate’s sealed dep set (workspace AGENTS.md) excludes tracing, so a built-in log line is not on the table.

The backend error parameter is accepted by reference (and discarded) so callers retain it for their own structured logging if they wire one. The returned JmapError always carries the static SERVER_FAIL_INTERNAL_DESC description; no caller-controlled text reaches the wire from this helper.

The function is generic over any Display (not just JmapBackend::Error) so the extension *-server crates’ own per-method handlers — which mix JmapBackend::Error, domain-specific error envelopes (BackendSetError::Other, BackendChangesError::Other), and trait-method errors — can call it uniformly.

§Use at every site that maps a backend error to serverFail

Replace:

.map_err(|e| JmapError::server_fail(e.to_string()))

with:

.map_err(|e| server_fail_from_backend(&e))