mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 03:47:02 +02:00
enable errors in updates
This commit is contained in:
parent
56686dee40
commit
1e4592dd7e
7 changed files with 52 additions and 86 deletions
|
@ -1,6 +1,8 @@
|
|||
use meilisearch_error::Code;
|
||||
use meilisearch_error::ErrorCode;
|
||||
|
||||
use crate::index::error::IndexError;
|
||||
|
||||
use super::dump_actor::error::DumpActorError;
|
||||
use super::index_actor::error::IndexActorError;
|
||||
use super::update_actor::error::UpdateActorError;
|
||||
|
@ -20,6 +22,8 @@ pub enum IndexControllerError {
|
|||
UpdateActor(#[from] UpdateActorError),
|
||||
#[error("error with dump: {0}")]
|
||||
DumpActor(#[from] DumpActorError),
|
||||
#[error("error with index: {0}")]
|
||||
IndexError(#[from] IndexError),
|
||||
}
|
||||
|
||||
impl ErrorCode for IndexControllerError {
|
||||
|
@ -30,6 +34,7 @@ impl ErrorCode for IndexControllerError {
|
|||
IndexControllerError::IndexActor(e) => e.error_code(),
|
||||
IndexControllerError::UpdateActor(e) => e.error_code(),
|
||||
IndexControllerError::DumpActor(e) => e.error_code(),
|
||||
IndexControllerError::IndexError(e) => e.error_code(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ use self::error::IndexControllerError;
|
|||
|
||||
mod dump_actor;
|
||||
pub mod error;
|
||||
mod index_actor;
|
||||
pub mod index_actor;
|
||||
mod snapshot;
|
||||
mod update_actor;
|
||||
mod updates;
|
||||
|
|
|
@ -332,7 +332,7 @@ impl UpdateStore {
|
|||
let result =
|
||||
match handle.block_on(index_handle.update(index_uuid, processing.clone(), file)) {
|
||||
Ok(result) => result,
|
||||
Err(e) => Err(processing.fail(e.to_string())),
|
||||
Err(e) => Err(processing.fail(e.into())),
|
||||
};
|
||||
|
||||
// Once the pending update have been successfully processed
|
||||
|
|
|
@ -3,9 +3,7 @@ use milli::update::{DocumentAdditionResult, IndexDocumentsMethod, UpdateFormat};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::index::{Settings, Unchecked};
|
||||
|
||||
pub type UpdateError = String;
|
||||
use crate::{error::ResponseError, index::{Settings, Unchecked}};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum UpdateResult {
|
||||
|
@ -116,7 +114,7 @@ impl Processing {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fail(self, error: UpdateError) -> Failed {
|
||||
pub fn fail(self, error: ResponseError) -> Failed {
|
||||
Failed {
|
||||
from: self,
|
||||
error,
|
||||
|
@ -143,12 +141,12 @@ impl Aborted {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Failed {
|
||||
#[serde(flatten)]
|
||||
pub from: Processing,
|
||||
pub error: UpdateError,
|
||||
pub error: ResponseError,
|
||||
pub failed_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
|
@ -162,7 +160,7 @@ impl Failed {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(tag = "status", rename_all = "camelCase")]
|
||||
pub enum UpdateStatus {
|
||||
Processing(Processing),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue