MCPcopy Create free account
hub / github.com/actix/examples / error_response

Method error_response

json/json-error/src/main.rs:22–25  ·  view source on GitHub ↗

builds the actual response to send back when an error occurs

(&self)

Source from the content-addressed store, hash-verified

20impl ResponseError for Error {
21 // builds the actual response to send back when an error occurs
22 fn error_response(&self) -> HttpResponse {
23 let err_json = serde_json::json!({ "error": self.msg });
24 HttpResponse::build(StatusCode::from_u16(self.status).unwrap()).json(err_json)
25 }
26}
27
28async fn index() -> Result<HttpResponse, Error> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected