mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-03-13 03:21:39 +01:00
Fix the error variants
This commit is contained in:
parent
0a4dbea30d
commit
26f0f1d638
@ -80,9 +80,13 @@ impl DocumentsBatchIndex {
|
|||||||
let mut map = Object::new();
|
let mut map = Object::new();
|
||||||
|
|
||||||
for (k, v) in document.iter() {
|
for (k, v) in document.iter() {
|
||||||
// TODO: TAMO: update the error type
|
let key = self
|
||||||
let key =
|
.0
|
||||||
self.0.get_by_left(&k).ok_or(crate::error::InternalError::DatabaseClosing)?.clone();
|
.get_by_left(&k)
|
||||||
|
.ok_or(crate::error::InternalError::FieldIdMapMissingEntry(
|
||||||
|
FieldIdMapMissingEntry::FieldId { field_id: k, process: "recreate_json" },
|
||||||
|
))?
|
||||||
|
.clone();
|
||||||
let value = serde_json::from_slice::<serde_json::Value>(v)
|
let value = serde_json::from_slice::<serde_json::Value>(v)
|
||||||
.map_err(crate::error::InternalError::SerdeJson)?;
|
.map_err(crate::error::InternalError::SerdeJson)?;
|
||||||
map.insert(key, value);
|
map.insert(key, value);
|
||||||
|
@ -33,8 +33,6 @@ pub enum Error {
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum InternalError {
|
pub enum InternalError {
|
||||||
#[error("{}", HeedError::DatabaseClosing)]
|
|
||||||
DatabaseClosing,
|
|
||||||
#[error("missing {} in the {db_name} database", key.unwrap_or("key"))]
|
#[error("missing {} in the {db_name} database", key.unwrap_or("key"))]
|
||||||
DatabaseMissingEntry { db_name: &'static str, key: Option<&'static str> },
|
DatabaseMissingEntry { db_name: &'static str, key: Option<&'static str> },
|
||||||
#[error("missing {key} in the fieldids weights mapping")]
|
#[error("missing {key} in the fieldids weights mapping")]
|
||||||
@ -186,8 +184,8 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
valid_fields: BTreeSet<String>,
|
valid_fields: BTreeSet<String>,
|
||||||
hidden_fields: bool,
|
hidden_fields: bool,
|
||||||
},
|
},
|
||||||
#[error("an environment is already opened with different options")]
|
#[error("An LMDB environment is already opened")]
|
||||||
InvalidLmdbOpenOptions,
|
EnvAlreadyOpened,
|
||||||
#[error("You must specify where `sort` is listed in the rankingRules setting to use the sort parameter at search time.")]
|
#[error("You must specify where `sort` is listed in the rankingRules setting to use the sort parameter at search time.")]
|
||||||
SortRankingRuleMissing,
|
SortRankingRuleMissing,
|
||||||
#[error("The database file is in an invalid state.")]
|
#[error("The database file is in an invalid state.")]
|
||||||
@ -505,8 +503,7 @@ impl From<HeedError> for Error {
|
|||||||
// TODO use the encoding
|
// TODO use the encoding
|
||||||
HeedError::Encoding(_) => InternalError(Serialization(Encoding { db_name: None })),
|
HeedError::Encoding(_) => InternalError(Serialization(Encoding { db_name: None })),
|
||||||
HeedError::Decoding(_) => InternalError(Serialization(Decoding { db_name: None })),
|
HeedError::Decoding(_) => InternalError(Serialization(Decoding { db_name: None })),
|
||||||
HeedError::DatabaseClosing => InternalError(DatabaseClosing),
|
HeedError::EnvAlreadyOpened { .. } => UserError(EnvAlreadyOpened),
|
||||||
HeedError::BadOpenOptions { .. } => UserError(InvalidLmdbOpenOptions),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user