mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 20:45:06 +08:00
36cb09eb25
Move `meilisearch_error` to `meilisearch_types::error` Move `meilisearch_lib::index_resolver::IndexUid` to `meilisearch_types::index_uid` Add a new `InvalidIndexUid` error in `meilisearch_types::index_uid`
35 lines
842 B
Rust
35 lines
842 B
Rust
use meilisearch_types::error::{Code, ErrorCode};
|
|
use meilisearch_types::internal_error;
|
|
use tokio::task::JoinError;
|
|
|
|
use crate::update_file_store::UpdateFileStoreError;
|
|
|
|
use super::task::TaskId;
|
|
|
|
pub type Result<T> = std::result::Result<T, TaskError>;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum TaskError {
|
|
#[error("Task `{0}` not found.")]
|
|
UnexistingTask(TaskId),
|
|
#[error("Internal error: {0}")]
|
|
Internal(Box<dyn std::error::Error + Send + Sync + 'static>),
|
|
}
|
|
|
|
internal_error!(
|
|
TaskError: milli::heed::Error,
|
|
JoinError,
|
|
std::io::Error,
|
|
serde_json::Error,
|
|
UpdateFileStoreError
|
|
);
|
|
|
|
impl ErrorCode for TaskError {
|
|
fn error_code(&self) -> Code {
|
|
match self {
|
|
TaskError::UnexistingTask(_) => Code::TaskNotFound,
|
|
TaskError::Internal(_) => Code::Internal,
|
|
}
|
|
}
|
|
}
|