enable errors in updates

This commit is contained in:
marin postma 2021-06-21 18:42:47 +02:00
parent 56686dee40
commit 1e4592dd7e
No known key found for this signature in database
GPG key ID: 6088B7721C3E39F9
7 changed files with 52 additions and 86 deletions

View file

@ -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(),
}
}
}

View file

@ -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;

View file

@ -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

View file

@ -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),