mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-11-04 09:56:28 +00:00 
			
		
		
		
	Fix the error variants
This commit is contained in:
		@@ -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::<serde_json::Value>(v)
 | 
			
		||||
                .map_err(crate::error::InternalError::SerdeJson)?;
 | 
			
		||||
            map.insert(key, value);
 | 
			
		||||
 
 | 
			
		||||
@@ -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")]
 | 
			
		||||
@@ -197,8 +195,8 @@ and can not be more than 511 bytes.", .document_id.to_string()
 | 
			
		||||
        valid_fields: BTreeSet<String>,
 | 
			
		||||
        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.")]
 | 
			
		||||
@@ -516,8 +514,7 @@ impl From<HeedError> 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),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user