mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Implement ErrorCode on the heed Error
This commit is contained in:
parent
91e13c2824
commit
c70f375669
@ -2,6 +2,7 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::{web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
|
use index::{Settings, Unchecked};
|
||||||
use index_scheduler::{IndexScheduler, Query, Status};
|
use index_scheduler::{IndexScheduler, Query, Status};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -2,6 +2,7 @@ use std::fmt;
|
|||||||
|
|
||||||
use actix_web::{self as aweb, http::StatusCode, HttpResponseBuilder};
|
use actix_web::{self as aweb, http::StatusCode, HttpResponseBuilder};
|
||||||
use aweb::rt::task::JoinError;
|
use aweb::rt::task::JoinError;
|
||||||
|
use milli::heed::{Error as HeedError, MdbError};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||||
@ -392,6 +393,22 @@ impl ErrorCode for milli::Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ErrorCode for HeedError {
|
||||||
|
fn error_code(&self) -> Code {
|
||||||
|
match self {
|
||||||
|
HeedError::Mdb(MdbError::MapFull) => Code::DatabaseSizeLimitReached,
|
||||||
|
HeedError::Mdb(MdbError::Invalid) => Code::InvalidStore,
|
||||||
|
HeedError::Io(_)
|
||||||
|
| HeedError::Mdb(_)
|
||||||
|
| HeedError::Encoding
|
||||||
|
| HeedError::Decoding
|
||||||
|
| HeedError::InvalidDatabaseTyping
|
||||||
|
| HeedError::DatabaseClosing
|
||||||
|
| HeedError::BadOpenOptions => Code::Internal,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "test-traits")]
|
#[cfg(feature = "test-traits")]
|
||||||
mod strategy {
|
mod strategy {
|
||||||
use proptest::strategy::Strategy;
|
use proptest::strategy::Strategy;
|
||||||
|
Loading…
Reference in New Issue
Block a user