Apply suggestion

- remove the payload_error_handler in favor of a PayloadError::from

- merge the two match branch into one

- makes the accepted content type a const instead of recalculating it for every error
This commit is contained in:
Tamo 2021-10-06 11:49:34 +02:00
parent 37b267ffb3
commit 9a1e44dc78
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
3 changed files with 38 additions and 39 deletions

View file

@ -30,6 +30,12 @@ impl ErrorCode for MeilisearchHttpError {
}
}
impl From<MeilisearchHttpError> for aweb::Error {
fn from(other: MeilisearchHttpError) -> Self {
aweb::Error::from(ResponseError::from(other))
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ResponseError {
@ -125,9 +131,8 @@ impl From<QueryPayloadError> for PayloadError {
}
}
pub fn payload_error_handler<E>(err: E) -> ResponseError
where
E: Into<PayloadError>,
{
err.into().into()
impl From<PayloadError> for aweb::Error {
fn from(other: PayloadError) -> Self {
aweb::Error::from(ResponseError::from(other))
}
}