mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
malformed payload error
This commit is contained in:
parent
137272b8de
commit
ddd40d87a7
@ -85,6 +85,7 @@ pub enum Code {
|
|||||||
DumpProcessFailed,
|
DumpProcessFailed,
|
||||||
|
|
||||||
MissingContentType,
|
MissingContentType,
|
||||||
|
MalformedPayload,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Code {
|
impl Code {
|
||||||
@ -157,6 +158,7 @@ impl Code {
|
|||||||
ErrCode::internal("dump_process_failed", StatusCode::INTERNAL_SERVER_ERROR)
|
ErrCode::internal("dump_process_failed", StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
}
|
}
|
||||||
MissingContentType => ErrCode::invalid("missing_content_type", StatusCode::UNSUPPORTED_MEDIA_TYPE),
|
MissingContentType => ErrCode::invalid("missing_content_type", StatusCode::UNSUPPORTED_MEDIA_TYPE),
|
||||||
|
MalformedPayload => ErrCode::invalid("malformed_payload", StatusCode::BAD_REQUEST)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ use std::fmt;
|
|||||||
use std::io::{self, Read, Result as IoResult, Seek, Write};
|
use std::io::{self, Read, Result as IoResult, Seek, Write};
|
||||||
|
|
||||||
use csv::{Reader as CsvReader, StringRecordsIntoIter};
|
use csv::{Reader as CsvReader, StringRecordsIntoIter};
|
||||||
|
use meilisearch_error::{Code, ErrorCode};
|
||||||
use milli::documents::DocumentBatchBuilder;
|
use milli::documents::DocumentBatchBuilder;
|
||||||
use serde_json::{Deserializer, Map, Value};
|
use serde_json::{Deserializer, Map, Value};
|
||||||
|
|
||||||
@ -35,6 +36,15 @@ pub enum DocumentFormatError {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ErrorCode for DocumentFormatError {
|
||||||
|
fn error_code(&self) -> Code {
|
||||||
|
match self {
|
||||||
|
DocumentFormatError::Internal(_) => Code::Internal,
|
||||||
|
DocumentFormatError::MalformedPayload(_, _) => Code::MalformedPayload,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal_error!(DocumentFormatError: milli::documents::Error, io::Error);
|
internal_error!(DocumentFormatError: milli::documents::Error, io::Error);
|
||||||
|
|
||||||
macro_rules! malformed {
|
macro_rules! malformed {
|
||||||
|
@ -22,9 +22,7 @@ pub enum UpdateLoopError {
|
|||||||
)]
|
)]
|
||||||
FatalUpdateStoreError,
|
FatalUpdateStoreError,
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
InvalidPayload(#[from] DocumentFormatError),
|
DocumentFormatError(#[from] DocumentFormatError),
|
||||||
#[error("{0}")]
|
|
||||||
MalformedPayload(Box<dyn Error + Send + Sync + 'static>),
|
|
||||||
// TODO: The reference to actix has to go.
|
// TODO: The reference to actix has to go.
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
PayloadError(#[from] actix_web::error::PayloadError),
|
PayloadError(#[from] actix_web::error::PayloadError),
|
||||||
@ -60,8 +58,7 @@ impl ErrorCode for UpdateLoopError {
|
|||||||
Self::Internal(_) => Code::Internal,
|
Self::Internal(_) => Code::Internal,
|
||||||
//Self::IndexActor(e) => e.error_code(),
|
//Self::IndexActor(e) => e.error_code(),
|
||||||
Self::FatalUpdateStoreError => Code::Internal,
|
Self::FatalUpdateStoreError => Code::Internal,
|
||||||
Self::InvalidPayload(_) => Code::BadRequest,
|
Self::DocumentFormatError(error) => error.error_code(),
|
||||||
Self::MalformedPayload(_) => Code::BadRequest,
|
|
||||||
Self::PayloadError(error) => match error {
|
Self::PayloadError(error) => match error {
|
||||||
actix_web::error::PayloadError::Overflow => Code::PayloadTooLarge,
|
actix_web::error::PayloadError::Overflow => Code::PayloadTooLarge,
|
||||||
_ => Code::Internal,
|
_ => Code::Internal,
|
||||||
|
Loading…
Reference in New Issue
Block a user