write_json_error

Function write_json_error 

Source
pub async fn write_json_error(
    session: &mut Session,
    status: u16,
    error: &str,
    message: Option<&str>,
) -> Result<(), Box<Error>>
Expand description

Write a JSON error response

Creates a JSON object with error and optional message fields.

§Example

// Produces: {"error":"not_found","message":"Resource does not exist"}
write_json_error(session, 404, "not_found", Some("Resource does not exist")).await?;