mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
remove anyhow refs & implement missing errors
This commit is contained in:
parent
c1b6f0e833
commit
58f9974be4
40 changed files with 707 additions and 668 deletions
40
meilisearch-http/src/index_controller/error.rs
Normal file
40
meilisearch-http/src/index_controller/error.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use std::error::Error;
|
||||
|
||||
use meilisearch_error::Code;
|
||||
use meilisearch_error::ErrorCode;
|
||||
|
||||
use super::dump_actor::error::DumpActorError;
|
||||
use super::index_actor::error::IndexActorError;
|
||||
use super::update_actor::error::UpdateActorError;
|
||||
use super::uuid_resolver::UuidResolverError;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, IndexControllerError>;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum IndexControllerError {
|
||||
#[error("Internal error: {0}")]
|
||||
Internal(Box<dyn Error>),
|
||||
#[error("Missing index uid")]
|
||||
MissingUid,
|
||||
#[error("error resolving index uid: {0}")]
|
||||
Uuid(#[from] UuidResolverError),
|
||||
#[error("error with index: {0}")]
|
||||
IndexActor(#[from] IndexActorError),
|
||||
#[error("error with update: {0}")]
|
||||
UpdateActor(#[from] UpdateActorError),
|
||||
#[error("error with dump: {0}")]
|
||||
DumpActor(#[from] DumpActorError),
|
||||
}
|
||||
|
||||
impl ErrorCode for IndexControllerError {
|
||||
fn error_code(&self) -> Code {
|
||||
match self {
|
||||
IndexControllerError::Internal(_) => Code::Internal,
|
||||
IndexControllerError::MissingUid => Code::InvalidIndexUid,
|
||||
IndexControllerError::Uuid(e) => e.error_code(),
|
||||
IndexControllerError::IndexActor(e) => e.error_code(),
|
||||
IndexControllerError::UpdateActor(e) => e.error_code(),
|
||||
IndexControllerError::DumpActor(e) => e.error_code(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue