pub fn to_handler_error(e: Error) -> (StatusCode, Json<ErrorResponse>)Expand description
Convert a [BackendError] (from the service layer) into the
best-fitting (StatusCode, Json<ErrorResponse>) pair returned by
every handler. The canonical call shape is
.map_err(to_handler_error)? at the end of each service call.
Status mapping (most-specific first):
NotFound,SessionNotFound,ConfigurationNotFound→ 404Conflict,ConfigurationAlreadyExistsError→ 409BadRequest,InvalidPattern,UnsupportedBackend,InvalidNodeId→ 400AuthenticationTokenNotFound,JwtMalformed→ 401InsufficientResources→ 422CsmError { status, .. }→ that backend status (verbatim) when it’s a valid HTTP code, else 502 Bad GatewayNetError(rqe)whererqe.is_timeout()→ 504 Gateway Timeout (manta-server → CSM hop)- everything else → 500 Internal Server Error
pub (rather than pub(crate)) so the integration tests in
crates/manta-server/tests/ can exercise the mapping directly.