mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
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:
parent
37b267ffb3
commit
9a1e44dc78
3 changed files with 38 additions and 39 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue