2021-12-06 15:45:41 +01:00
|
|
|
use meilisearch_auth::error::AuthControllerError;
|
2021-11-08 18:31:27 +01:00
|
|
|
use meilisearch_error::{internal_error, Code, ErrorCode};
|
2021-06-14 21:26:35 +02:00
|
|
|
|
2021-12-02 16:03:26 +01:00
|
|
|
use crate::{index_resolver::error::IndexResolverError, tasks::error::TaskError};
|
2021-06-14 21:26:35 +02:00
|
|
|
|
|
|
|
pub type Result<T> = std::result::Result<T, DumpActorError>;
|
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
pub enum DumpActorError {
|
2021-11-03 14:25:49 +01:00
|
|
|
#[error("A dump is already processing. You must wait until the current process is finished before requesting another dump.")]
|
2021-06-14 21:26:35 +02:00
|
|
|
DumpAlreadyRunning,
|
2021-10-26 19:36:48 +02:00
|
|
|
#[error("Dump `{0}` not found.")]
|
2021-06-14 21:26:35 +02:00
|
|
|
DumpDoesNotExist(String),
|
2021-11-03 14:25:49 +01:00
|
|
|
#[error("An internal error has occurred. `{0}`.")]
|
2021-06-14 21:26:35 +02:00
|
|
|
Internal(Box<dyn std::error::Error + Send + Sync + 'static>),
|
2021-06-24 10:53:51 +02:00
|
|
|
#[error("{0}")]
|
2021-09-24 11:53:11 +02:00
|
|
|
IndexResolver(#[from] IndexResolverError),
|
2021-06-14 21:26:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
internal_error!(
|
2022-03-16 13:45:58 +01:00
|
|
|
DumpActorError: milli::heed::Error,
|
2021-06-14 21:26:35 +02:00
|
|
|
std::io::Error,
|
|
|
|
tokio::task::JoinError,
|
2021-12-02 16:03:26 +01:00
|
|
|
tokio::sync::oneshot::error::RecvError,
|
2021-06-14 21:26:35 +02:00
|
|
|
serde_json::error::Error,
|
2021-12-02 16:03:26 +01:00
|
|
|
tempfile::PersistError,
|
|
|
|
fs_extra::error::Error,
|
2021-12-06 15:45:41 +01:00
|
|
|
AuthControllerError,
|
2021-12-02 16:03:26 +01:00
|
|
|
TaskError
|
2021-06-14 21:26:35 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
impl ErrorCode for DumpActorError {
|
|
|
|
fn error_code(&self) -> Code {
|
|
|
|
match self {
|
|
|
|
DumpActorError::DumpAlreadyRunning => Code::DumpAlreadyInProgress,
|
2021-11-03 14:25:49 +01:00
|
|
|
DumpActorError::DumpDoesNotExist(_) => Code::DumpNotFound,
|
2021-06-14 21:26:35 +02:00
|
|
|
DumpActorError::Internal(_) => Code::Internal,
|
2021-09-24 11:53:11 +02:00
|
|
|
DumpActorError::IndexResolver(e) => e.error_code(),
|
2021-06-14 21:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|