mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14:27 +01:00
decompose error messages
This commit is contained in:
parent
a2368db154
commit
a1d34faaad
@ -12,9 +12,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum AuthenticationError {
|
pub enum AuthenticationError {
|
||||||
#[error("you must have an authorization token")]
|
#[error("You must have an authorization token")]
|
||||||
MissingAuthorizationHeader,
|
MissingAuthorizationHeader,
|
||||||
#[error("invalid API key")]
|
#[error("Invalid API key")]
|
||||||
InvalidToken(String),
|
InvalidToken(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ pub type Result<T> = std::result::Result<T, IndexError>;
|
|||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum IndexError {
|
pub enum IndexError {
|
||||||
#[error("internal error: {0}")]
|
#[error("Internal error: {0}")]
|
||||||
Internal(Box<dyn Error + Send + Sync + 'static>),
|
Internal(Box<dyn Error + Send + Sync + 'static>),
|
||||||
#[error("document with id {0} not found.")]
|
#[error("Document with id {0} not found.")]
|
||||||
DocumentNotFound(String),
|
DocumentNotFound(String),
|
||||||
#[error("error with facet: {0}")]
|
#[error("{0}")]
|
||||||
Facet(#[from] FacetError),
|
Facet(#[from] FacetError),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Milli(#[from] milli::Error),
|
Milli(#[from] milli::Error),
|
||||||
@ -39,7 +39,7 @@ impl ErrorCode for IndexError {
|
|||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum FacetError {
|
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),
|
InvalidExpression(&'static [&'static str], Value),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,15 +7,15 @@ pub type Result<T> = std::result::Result<T, DumpActorError>;
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum DumpActorError {
|
pub enum DumpActorError {
|
||||||
#[error("dump already running")]
|
#[error("Another dump is already in progress")]
|
||||||
DumpAlreadyRunning,
|
DumpAlreadyRunning,
|
||||||
#[error("dump `{0}` does not exist")]
|
#[error("Dump `{0}` not found")]
|
||||||
DumpDoesNotExist(String),
|
DumpDoesNotExist(String),
|
||||||
#[error("internal error: {0}")]
|
#[error("Internal error: {0}")]
|
||||||
Internal(Box<dyn std::error::Error + Send + Sync + 'static>),
|
Internal(Box<dyn std::error::Error + Send + Sync + 'static>),
|
||||||
#[error("error while dumping uuids: {0}")]
|
#[error("{0}")]
|
||||||
UuidResolver(#[from] UuidResolverError),
|
UuidResolver(#[from] UuidResolverError),
|
||||||
#[error("error while dumping updates: {0}")]
|
#[error("{0}")]
|
||||||
UpdateActor(#[from] UpdateActorError),
|
UpdateActor(#[from] UpdateActorError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,24 +12,24 @@ pub type Result<T> = std::result::Result<T, IndexControllerError>;
|
|||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum IndexControllerError {
|
pub enum IndexControllerError {
|
||||||
#[error("missing index uid")]
|
#[error("Index creation must have an uid")]
|
||||||
MissingUid,
|
MissingUid,
|
||||||
#[error("index resolution error: {0}")]
|
#[error("{0}")]
|
||||||
Uuid(#[from] UuidResolverError),
|
Uuid(#[from] UuidResolverError),
|
||||||
#[error("error with index: {0}")]
|
#[error("{0}")]
|
||||||
IndexActor(#[from] IndexActorError),
|
IndexActor(#[from] IndexActorError),
|
||||||
#[error("error with update: {0}")]
|
#[error("{0}")]
|
||||||
UpdateActor(#[from] UpdateActorError),
|
UpdateActor(#[from] UpdateActorError),
|
||||||
#[error("error with dump: {0}")]
|
#[error("{0}")]
|
||||||
DumpActor(#[from] DumpActorError),
|
DumpActor(#[from] DumpActorError),
|
||||||
#[error("error with index: {0}")]
|
#[error("{0}")]
|
||||||
IndexError(#[from] IndexError),
|
IndexError(#[from] IndexError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorCode for IndexControllerError {
|
impl ErrorCode for IndexControllerError {
|
||||||
fn error_code(&self) -> Code {
|
fn error_code(&self) -> Code {
|
||||||
match self {
|
match self {
|
||||||
IndexControllerError::MissingUid => Code::InvalidIndexUid,
|
IndexControllerError::MissingUid => Code::BadRequest,
|
||||||
IndexControllerError::Uuid(e) => e.error_code(),
|
IndexControllerError::Uuid(e) => e.error_code(),
|
||||||
IndexControllerError::IndexActor(e) => e.error_code(),
|
IndexControllerError::IndexActor(e) => e.error_code(),
|
||||||
IndexControllerError::UpdateActor(e) => e.error_code(),
|
IndexControllerError::UpdateActor(e) => e.error_code(),
|
||||||
|
@ -6,15 +6,15 @@ pub type Result<T> = std::result::Result<T, IndexActorError>;
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum IndexActorError {
|
pub enum IndexActorError {
|
||||||
#[error("index error: {0}")]
|
#[error("{0}")]
|
||||||
IndexError(#[from] IndexError),
|
IndexError(#[from] IndexError),
|
||||||
#[error("index already exists")]
|
#[error("Index already exists")]
|
||||||
IndexAlreadyExists,
|
IndexAlreadyExists,
|
||||||
#[error("index doesn't exists")]
|
#[error("Index not found")]
|
||||||
UnexistingIndex,
|
UnexistingIndex,
|
||||||
#[error("existing primary key")]
|
#[error("A primary key is already present. It's impossible to update it")]
|
||||||
ExistingPrimaryKey,
|
ExistingPrimaryKey,
|
||||||
#[error("internal Index Error: {0}")]
|
#[error("Internal Error: {0}")]
|
||||||
Internal(Box<dyn std::error::Error + Send + Sync + 'static>),
|
Internal(Box<dyn std::error::Error + Send + Sync + 'static>),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Milli(#[from] milli::Error),
|
Milli(#[from] milli::Error),
|
||||||
|
@ -9,19 +9,19 @@ pub type Result<T> = std::result::Result<T, UpdateActorError>;
|
|||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdateActorError {
|
pub enum UpdateActorError {
|
||||||
#[error("update {0} doesn't exist.")]
|
#[error("Update {0} not found.")]
|
||||||
UnexistingUpdate(u64),
|
UnexistingUpdate(u64),
|
||||||
#[error("internal error processing update: {0}")]
|
#[error("Internal error: {0}")]
|
||||||
Internal(Box<dyn Error + Send + Sync + 'static>),
|
Internal(Box<dyn Error + Send + Sync + 'static>),
|
||||||
#[error("error with index: {0}")]
|
#[error("{0}")]
|
||||||
IndexActor(#[from] IndexActorError),
|
IndexActor(#[from] IndexActorError),
|
||||||
#[error(
|
#[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,
|
FatalUpdateStoreError,
|
||||||
#[error("invalid payload: {0}")]
|
#[error("{0}")]
|
||||||
InvalidPayload(Box<dyn Error + Send + Sync + 'static>),
|
InvalidPayload(Box<dyn Error + Send + Sync + 'static>),
|
||||||
#[error("payload error: {0}")]
|
#[error("{0}")]
|
||||||
PayloadError(#[from] actix_web::error::PayloadError),
|
PayloadError(#[from] actix_web::error::PayloadError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ pub type Result<T> = std::result::Result<T, UuidResolverError>;
|
|||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum UuidResolverError {
|
pub enum UuidResolverError {
|
||||||
#[error("name already exist.")]
|
#[error("Index already exists.")]
|
||||||
NameAlreadyExist,
|
NameAlreadyExist,
|
||||||
#[error("index \"{0}\" doesn't exist.")]
|
#[error("Index \"{0}\" not found.")]
|
||||||
UnexistingIndex(String),
|
UnexistingIndex(String),
|
||||||
#[error("badly formatted index uid: {0}")]
|
#[error("Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).")]
|
||||||
BadlyFormatted(String),
|
BadlyFormatted(String),
|
||||||
#[error("internal error resolving index uid: {0}")]
|
#[error("Internal error: {0}")]
|
||||||
Internal(Box<dyn std::error::Error + Sync + Send + 'static>),
|
Internal(Box<dyn std::error::Error + Sync + Send + 'static>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user