mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-06-06 21:07:47 +02:00
a30e02c18c
implements: https://github.com/meilisearch/specifications/blob/develop/text/0060-refashion-updates-apis.md linked PR: - #1889 - #1891 - #1892 - #1902 - #1906 - #1911 - #1914 - #1915 - #1916 - #1918 - #1924 - #1925 - #1926 - #1930 - #1936 - #1937 - #1942 - #1944 - #1945 - #1946 - #1947 - #1950 - #1951 - #1957 - #1959 - #1960 - #1961 - #1962 - #1964 - https://github.com/meilisearch/milli/pull/414 - https://github.com/meilisearch/milli/pull/409 - https://github.com/meilisearch/milli/pull/406 - https://github.com/meilisearch/milli/pull/418 - close #1687 - close #1786 - close #1940 - close #1948 - close #1949 - close #1932 - close #1956
69 lines
2.4 KiB
Rust
69 lines
2.4 KiB
Rust
use std::error::Error;
|
|
|
|
use meilisearch_error::Code;
|
|
use meilisearch_error::ErrorCode;
|
|
use tokio::task::JoinError;
|
|
|
|
use super::DocumentAdditionFormat;
|
|
use crate::document_formats::DocumentFormatError;
|
|
use crate::index::error::IndexError;
|
|
use crate::tasks::error::TaskError;
|
|
use crate::update_file_store::UpdateFileStoreError;
|
|
|
|
use super::dump_actor::error::DumpActorError;
|
|
use crate::index_resolver::error::IndexResolverError;
|
|
|
|
pub type Result<T> = std::result::Result<T, IndexControllerError>;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum IndexControllerError {
|
|
#[error("Index creation must have an uid")]
|
|
MissingUid,
|
|
#[error("{0}")]
|
|
IndexResolver(#[from] IndexResolverError),
|
|
#[error("{0}")]
|
|
IndexError(#[from] IndexError),
|
|
#[error("An internal error has occurred. `{0}`.")]
|
|
Internal(Box<dyn Error + Send + Sync + 'static>),
|
|
#[error("{0}")]
|
|
TaskError(#[from] TaskError),
|
|
#[error("{0}")]
|
|
DumpError(#[from] DumpActorError),
|
|
#[error("{0}")]
|
|
DocumentFormatError(#[from] DocumentFormatError),
|
|
#[error("A {0} payload is missing.")]
|
|
MissingPayload(DocumentAdditionFormat),
|
|
#[error("The provided payload reached the size limit.")]
|
|
PayloadTooLarge,
|
|
}
|
|
|
|
internal_error!(IndexControllerError: JoinError, UpdateFileStoreError);
|
|
|
|
impl From<actix_web::error::PayloadError> for IndexControllerError {
|
|
fn from(other: actix_web::error::PayloadError) -> Self {
|
|
match other {
|
|
actix_web::error::PayloadError::Overflow => Self::PayloadTooLarge,
|
|
_ => Self::Internal(Box::new(other)),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ErrorCode for IndexControllerError {
|
|
fn error_code(&self) -> Code {
|
|
match self {
|
|
IndexControllerError::MissingUid => Code::BadRequest,
|
|
IndexControllerError::IndexResolver(e) => e.error_code(),
|
|
IndexControllerError::IndexError(e) => e.error_code(),
|
|
IndexControllerError::Internal(_) => Code::Internal,
|
|
IndexControllerError::TaskError(e) => e.error_code(),
|
|
IndexControllerError::DocumentFormatError(e) => e.error_code(),
|
|
IndexControllerError::MissingPayload(_) => Code::MissingPayload,
|
|
IndexControllerError::PayloadTooLarge => Code::PayloadTooLarge,
|
|
IndexControllerError::DumpError(DumpActorError::DumpAlreadyRunning) => {
|
|
Code::DumpAlreadyInProgress
|
|
}
|
|
IndexControllerError::DumpError(_) => Code::DumpProcessFailed,
|
|
}
|
|
}
|
|
}
|