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
|
|
|
|
2022-05-19 14:44:24 +02:00
|
|
|
pub type Result<T> = std::result::Result<T, DumpError>;
|
2021-06-14 21:26:35 +02:00
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
2022-05-19 14:44:24 +02:00
|
|
|
pub enum DumpError {
|
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-05-19 14:44:24 +02:00
|
|
|
DumpError: 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
|
|
|
);
|
|
|
|
|
2022-05-19 14:44:24 +02:00
|
|
|
impl ErrorCode for DumpError {
|
2021-06-14 21:26:35 +02:00
|
|
|
fn error_code(&self) -> Code {
|
|
|
|
match self {
|
2022-05-19 14:44:24 +02:00
|
|
|
DumpError::Internal(_) => Code::Internal,
|
|
|
|
DumpError::IndexResolver(e) => e.error_code(),
|
2021-06-14 21:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|