diff --git a/meilisearch-http/src/error.rs b/meilisearch-http/src/error.rs index f715399ff..161aa6e8c 100644 --- a/meilisearch-http/src/error.rs +++ b/meilisearch-http/src/error.rs @@ -14,9 +14,9 @@ use crate::index_controller::error::IndexControllerError; #[derive(Debug, thiserror::Error)] pub enum AuthenticationError { - #[error("You must have an authorization token")] + #[error("you must have an authorization token")] MissingAuthorizationHeader, - #[error("Invalid API key")] + #[error("invalid API key")] InvalidToken(String), } diff --git a/meilisearch-http/src/index/dump.rs b/meilisearch-http/src/index/dump.rs index 92513d10f..52a5cabd9 100644 --- a/meilisearch-http/src/index/dump.rs +++ b/meilisearch-http/src/index/dump.rs @@ -3,7 +3,7 @@ use std::io::{BufRead, BufReader, Write}; use std::path::Path; use std::sync::Arc; -use anyhow::Context; +use anyhow::{Context, bail}; use heed::RoTxn; use indexmap::IndexMap; use milli::update::{IndexDocumentsMethod, UpdateFormat::JsonStream}; @@ -126,7 +126,7 @@ impl Index { match Arc::try_unwrap(index.0) { Ok(inner) => inner.prepare_for_closing().wait(), - Err(_) => todo!("Could not close index properly."), + Err(_) => bail!("Could not close index properly."), } Ok(()) diff --git a/meilisearch-http/src/index/error.rs b/meilisearch-http/src/index/error.rs index 7692c57f0..b9bf71a3b 100644 --- a/meilisearch-http/src/index/error.rs +++ b/meilisearch-http/src/index/error.rs @@ -9,9 +9,9 @@ pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum IndexError { - #[error("Internal error: {0}")] + #[error("internal error: {0}")] Internal(Box), - #[error("Document with id {0} not found.")] + #[error("document with id {0} not found.")] DocumentNotFound(String), #[error("error with facet: {0}")] Facet(#[from] FacetError), @@ -39,7 +39,7 @@ impl ErrorCode for IndexError { #[derive(Debug, thiserror::Error)] pub enum FacetError { - #[error("Invalid facet expression, expected {}, found: {1}", .0.join(", "))] + #[error("invalid facet expression, expected {}, found: {1}", .0.join(", "))] InvalidExpression(&'static [&'static str], Value), } diff --git a/meilisearch-http/src/index_controller/dump_actor/error.rs b/meilisearch-http/src/index_controller/dump_actor/error.rs index 778b6b25c..ed693d5f3 100644 --- a/meilisearch-http/src/index_controller/dump_actor/error.rs +++ b/meilisearch-http/src/index_controller/dump_actor/error.rs @@ -11,7 +11,7 @@ pub enum DumpActorError { DumpAlreadyRunning, #[error("dump `{0}` does not exist")] DumpDoesNotExist(String), - #[error("Internal error: {0}")] + #[error("internal error: {0}")] Internal(Box), #[error("error while dumping uuids: {0}")] UuidResolver(#[from] UuidResolverError), diff --git a/meilisearch-http/src/index_controller/error.rs b/meilisearch-http/src/index_controller/error.rs index 0862c299e..956a755ab 100644 --- a/meilisearch-http/src/index_controller/error.rs +++ b/meilisearch-http/src/index_controller/error.rs @@ -10,7 +10,7 @@ pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum IndexControllerError { - #[error("Missing index uid")] + #[error("missing index uid")] MissingUid, #[error("index resolution error: {0}")] Uuid(#[from] UuidResolverError), diff --git a/meilisearch-http/src/index_controller/index_actor/error.rs b/meilisearch-http/src/index_controller/index_actor/error.rs index 37b43980c..244797234 100644 --- a/meilisearch-http/src/index_controller/index_actor/error.rs +++ b/meilisearch-http/src/index_controller/index_actor/error.rs @@ -10,11 +10,11 @@ pub enum IndexActorError { IndexError(#[from] IndexError), #[error("index already exists")] IndexAlreadyExists, - #[error("Index doesn't exists")] + #[error("index doesn't exists")] UnexistingIndex, - #[error("Existing primary key")] + #[error("existing primary key")] ExistingPrimaryKey, - #[error("Internal Index Error: {0}")] + #[error("internal Index Error: {0}")] Internal(Box), #[error("{0}")] Milli(#[from] milli::Error), diff --git a/meilisearch-http/src/index_controller/mod.rs b/meilisearch-http/src/index_controller/mod.rs index d82eb3d30..1d1a8f1cc 100644 --- a/meilisearch-http/src/index_controller/mod.rs +++ b/meilisearch-http/src/index_controller/mod.rs @@ -330,10 +330,10 @@ impl IndexController { pub async fn update_index( &self, uid: String, - index_settings: IndexSettings, + mut index_settings: IndexSettings, ) -> Result { if index_settings.uid.is_some() { - todo!("Can't change the index uid.") + index_settings.uid.take(); } let uuid = self.uuid_resolver.get(uid.clone()).await?; diff --git a/meilisearch-http/src/index_controller/snapshot.rs b/meilisearch-http/src/index_controller/snapshot.rs index ed2d6cb8a..9f0c5c0ba 100644 --- a/meilisearch-http/src/index_controller/snapshot.rs +++ b/meilisearch-http/src/index_controller/snapshot.rs @@ -1,6 +1,7 @@ use std::path::{Path, PathBuf}; use std::time::Duration; +use anyhow::bail; use log::{error, info}; use tokio::fs; use tokio::task::spawn_blocking; @@ -108,7 +109,7 @@ pub fn load_snapshot( } } } else if db_path.as_ref().exists() && !ignore_snapshot_if_db_exists { - todo!( + bail!( "database already exists at {:?}, try to delete it or rename it", db_path .as_ref() @@ -116,7 +117,7 @@ pub fn load_snapshot( .unwrap_or_else(|_| db_path.as_ref().to_owned()) ) } else if !snapshot_path.as_ref().exists() && !ignore_missing_snapshot { - todo!( + bail!( "snapshot doesn't exist at {:?}", snapshot_path .as_ref() diff --git a/meilisearch-http/src/index_controller/update_actor/error.rs b/meilisearch-http/src/index_controller/update_actor/error.rs index a78e6576f..9324c424b 100644 --- a/meilisearch-http/src/index_controller/update_actor/error.rs +++ b/meilisearch-http/src/index_controller/update_actor/error.rs @@ -9,14 +9,14 @@ pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] #[allow(clippy::large_enum_variant)] pub enum UpdateActorError { - #[error("Update {0} doesn't exist.")] + #[error("update {0} doesn't exist.")] UnexistingUpdate(u64), - #[error("Internal error processing update: {0}")] + #[error("internal error processing update: {0}")] Internal(Box), #[error("error with index: {0}")] IndexActor(#[from] IndexActorError), #[error( - "Update store was shut down due to a fatal error, please check your logs for more info." + "update store was shut down due to a fatal error, please check your logs for more info." )] FatalUpdateStoreError, } diff --git a/meilisearch-http/src/index_controller/uuid_resolver/error.rs b/meilisearch-http/src/index_controller/uuid_resolver/error.rs index 30cde08c1..3d7fb8444 100644 --- a/meilisearch-http/src/index_controller/uuid_resolver/error.rs +++ b/meilisearch-http/src/index_controller/uuid_resolver/error.rs @@ -4,13 +4,13 @@ pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum UuidResolverError { - #[error("Name already exist.")] + #[error("name already exist.")] NameAlreadyExist, - #[error("Index \"{0}\" doesn't exist.")] + #[error("index \"{0}\" doesn't exist.")] UnexistingIndex(String), - #[error("Badly formatted index uid: {0}")] + #[error("badly formatted index uid: {0}")] BadlyFormatted(String), - #[error("Internal error resolving index uid: {0}")] + #[error("internal error resolving index uid: {0}")] Internal(Box), }