Skip to main content

error_status

Function error_status 

Source
pub fn error_status(err: &JmapError) -> StatusCode
Expand description

Map a JmapError type string to the appropriate HTTP status code.

Error type strings are per RFC 8620 §7.1.

§Request-level errors only

Only request-level errors should flow through this function. Method-level errors (accountNotFound, notFound, unknownMethod, etc.) belong in methodResponses at HTTP 200 via error_invocation — they must never reach error_status. Passing a method-level error here is a caller bug; the catch-all maps unrecognized types to 500 rather than silently returning a wrong status code.

Request-level error types (safe to pass here): notJSON, notRequest, limit, unknownCapability, invalidArguments, requestTooLarge, forbidden, serverFail, serverUnavailable.