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

Method error_response

auth/simple-auth-server/src/errors.rs:20–28  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

18// impl ResponseError trait allows to convert our errors into http responses with appropriate data
19impl ResponseError for ServiceError {
20 fn error_response(&self) -> HttpResponse {
21 match self {
22 ServiceError::InternalServerError => {
23 HttpResponse::InternalServerError().json("Internal Server Error, Please try later")
24 }
25 ServiceError::BadRequest(message) => HttpResponse::BadRequest().json(message),
26 ServiceError::Unauthorized => HttpResponse::Unauthorized().json("Unauthorized"),
27 }
28 }
29}
30
31// we can return early in our handlers if UUID provided by the user is not valid

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected