Improve HTTP request error messages

Closes #153
This commit is contained in:
Tobie Morgan Hitchcock 2022-09-16 00:41:16 +01:00
parent 87777aba03
commit b2f4101a9c

View file

@ -58,7 +58,7 @@ pub async fn recover(err: warp::Rejection) -> Result<impl warp::Reply, warp::Rej
Ok(warp::reply::with_status(
warp::reply::json(&Message {
code: 405,
details: Some("Request content length too large".to_string()),
details: Some("Requested method not allowed".to_string()),
description: Some("The requested http method is not allowed for this resource. Refer to the documentation for allowed methods.".to_string()),
information: None,
}),
@ -78,7 +78,7 @@ pub async fn recover(err: warp::Rejection) -> Result<impl warp::Reply, warp::Rej
Ok(warp::reply::with_status(
warp::reply::json(&Message {
code: 413,
details: Some("Request problems detected".to_string()),
details: Some("Payload too large".to_string()),
description: Some("The request has exceeded the maximum payload size. Refer to the documentation for the request limitations.".to_string()),
information: None,
}),
@ -88,7 +88,7 @@ pub async fn recover(err: warp::Rejection) -> Result<impl warp::Reply, warp::Rej
Ok(warp::reply::with_status(
warp::reply::json(&Message {
code: 415,
details: Some("Unsupported content type requested".to_string()),
details: Some("Unsupported media type".to_string()),
description: Some("The request needs to adhere to certain constraints. Refer to the documentation for supported content types.".to_string()),
information: None,
}),
@ -98,7 +98,7 @@ pub async fn recover(err: warp::Rejection) -> Result<impl warp::Reply, warp::Rej
Ok(warp::reply::with_status(
warp::reply::json(&Message {
code: 501,
details: Some("Not Implemented".to_string()),
details: Some("Not implemented".to_string()),
description: Some("The server either does not recognize the query, or it lacks the ability to fulfill the request.".to_string()),
information: None,
}),
@ -108,7 +108,7 @@ pub async fn recover(err: warp::Rejection) -> Result<impl warp::Reply, warp::Rej
Ok(warp::reply::with_status(
warp::reply::json(&Message {
code: 501,
details: Some("Not Implemented".to_string()),
details: Some("Not implemented".to_string()),
description: Some("The server either does not recognize a request header, or it lacks the ability to fulfill the request.".to_string()),
information: None,
}),