MCPcopy Create free account
hub / github.com/ElementsProject/lightning / into_response

Method into_response

plugins/rest-plugin/src/structs.rs:39–53  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

37
38impl IntoResponse for AppError {
39 fn into_response(self) -> Response {
40 let (status, error_message) = match self {
41 AppError::BadRequest(err) => (StatusCode::BAD_REQUEST, err),
42 AppError::Unauthorized(err) => (StatusCode::UNAUTHORIZED, err),
43 AppError::Forbidden(err) => (StatusCode::FORBIDDEN, err),
44 AppError::NotFound(err) => (StatusCode::NOT_FOUND, err),
45 AppError::MethodNotAllowed(err) => (StatusCode::METHOD_NOT_ALLOWED, err),
46 AppError::InternalServerError(err) => (StatusCode::INTERNAL_SERVER_ERROR, err),
47 AppError::NotAcceptable(err) => (StatusCode::NOT_ACCEPTABLE, err),
48 AppError::PayloadTooLarge(err) => (StatusCode::PAYLOAD_TOO_LARGE, err),
49 };
50
51 let body = Json(json!(error_message));
52 (status, body).into_response()
53 }
54}
55
56impl std::fmt::Display for AppError {

Callers 2

convert_json_to_responseFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected