error_to_json

Attribute Macro error_to_json 

Source
#[error_to_json]
Expand description

convert actix_web error to 200 OK and json body

#[error_to_json]
#[get("/index")]
async fn test() -> Result<HttpResponse> {
    Err(ErrorInternalServerError("some error"))
}

will convert to

#[get("index")]
async fn test() -> Result<HttpResponse> {
    Ok(HttpResponse::Ok().body(r#"{"errors":[{"detail": "some error"}]}"#))
}