mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
refactor errors / isolate core/http errors
This commit is contained in:
parent
e2db197b3f
commit
d69180ec67
29 changed files with 585 additions and 480 deletions
|
@ -7,7 +7,7 @@ use actix_service::{Service, Transform};
|
|||
use actix_web::{dev::ServiceRequest, dev::ServiceResponse};
|
||||
use futures::future::{err, ok, Future, Ready};
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::error::{Error, ResponseError};
|
||||
use crate::Data;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -71,10 +71,10 @@ where
|
|||
let auth_header = match req.headers().get("X-Meili-API-Key") {
|
||||
Some(auth) => match auth.to_str() {
|
||||
Ok(auth) => auth,
|
||||
Err(_) => return Box::pin(err(Error::MissingAuthorizationHeader.into())),
|
||||
Err(_) => return Box::pin(err(ResponseError::from(Error::MissingAuthorizationHeader).into())),
|
||||
},
|
||||
None => {
|
||||
return Box::pin(err(Error::MissingAuthorizationHeader.into()));
|
||||
return Box::pin(err(ResponseError::from(Error::MissingAuthorizationHeader).into()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -95,7 +95,7 @@ where
|
|||
Box::pin(svc.call(req))
|
||||
} else {
|
||||
Box::pin(err(
|
||||
Error::InvalidToken(auth_header.to_string()).into()
|
||||
ResponseError::from(Error::InvalidToken(auth_header.to_string())).into()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use serde_json::Value;
|
|||
use siphasher::sip::SipHasher;
|
||||
use slice_group_by::GroupBy;
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::error::{Error, ResponseError};
|
||||
|
||||
pub trait IndexSearchExt {
|
||||
fn new_search(&self, query: String) -> SearchBuilder;
|
||||
|
@ -107,7 +107,7 @@ impl<'a> SearchBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn search(self, reader: &heed::RoTxn<MainT>) -> Result<SearchResult, Error> {
|
||||
pub fn search(self, reader: &heed::RoTxn<MainT>) -> Result<SearchResult, ResponseError> {
|
||||
let schema = self
|
||||
.index
|
||||
.main
|
||||
|
@ -260,7 +260,7 @@ impl<'a> SearchBuilder<'a> {
|
|||
reader: &heed::RoTxn<MainT>,
|
||||
ranked_map: &'a RankedMap,
|
||||
schema: &Schema,
|
||||
) -> Result<Option<Criteria<'a>>, Error> {
|
||||
) -> Result<Option<Criteria<'a>>, ResponseError> {
|
||||
let ranking_rules = self.index.main.ranking_rules(reader)?;
|
||||
|
||||
if let Some(ranking_rules) = ranking_rules {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue