Skip to main content

error_value

Function error_value 

Source
pub fn error_value(message: impl Into<String>) -> Value
Expand description

The value of the "error" key in bamboo’s canonical error envelope ({"error": {"message", "type", "code"}}, matching AppError’s ResponseError::error_response body) — for the minority of handlers that are not (yet) modeled as an AppError variant but still need to return extra sibling fields alongside the error (e.g. session_id, message_id) that a bare AppError has no place for.

Prefer returning Result<_, AppError> directly when there are no extra sibling fields — this helper exists only to converge the remaining hand-written HttpResponse::X().json(json!({"error": "<flat string>", ...})) call sites (#251 finding 2) onto the SAME envelope shape as AppError, without forcing every one of them through a full AppError variant.

§Example

HttpResponse::NotFound().json(serde_json::json!({
    "error": error_value("Session not found"),
    "session_id": session_id,
}))