diff --git a/crates/milli/src/documents/mod.rs b/crates/milli/src/documents/mod.rs index 88fa38d30..f43f7e842 100644 --- a/crates/milli/src/documents/mod.rs +++ b/crates/milli/src/documents/mod.rs @@ -80,9 +80,13 @@ impl DocumentsBatchIndex { let mut map = Object::new(); for (k, v) in document.iter() { - // TODO: TAMO: update the error type - let key = - self.0.get_by_left(&k).ok_or(crate::error::InternalError::DatabaseClosing)?.clone(); + let key = self + .0 + .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::(v) .map_err(crate::error::InternalError::SerdeJson)?; map.insert(key, value); diff --git a/crates/milli/src/error.rs b/crates/milli/src/error.rs index c977362d6..3dfd3ce0b 100644 --- a/crates/milli/src/error.rs +++ b/crates/milli/src/error.rs @@ -33,8 +33,6 @@ pub enum Error { #[derive(Error, Debug)] pub enum InternalError { - #[error("{}", HeedError::DatabaseClosing)] - DatabaseClosing, #[error("missing {} in the {db_name} database", key.unwrap_or("key"))] DatabaseMissingEntry { db_name: &'static str, key: Option<&'static str> }, #[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, hidden_fields: bool, }, - #[error("an environment is already opened with different options")] - InvalidLmdbOpenOptions, + #[error("An LMDB environment is already opened")] + EnvAlreadyOpened, #[error("You must specify where `sort` is listed in the rankingRules setting to use the sort parameter at search time.")] SortRankingRuleMissing, #[error("The database file is in an invalid state.")] @@ -505,8 +503,7 @@ impl From for Error { // TODO use the encoding HeedError::Encoding(_) => InternalError(Serialization(Encoding { db_name: None })), HeedError::Decoding(_) => InternalError(Serialization(Decoding { db_name: None })), - HeedError::DatabaseClosing => InternalError(DatabaseClosing), - HeedError::BadOpenOptions { .. } => UserError(InvalidLmdbOpenOptions), + HeedError::EnvAlreadyOpened { .. } => UserError(EnvAlreadyOpened), } } }