mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-19 01:18:31 +08:00
implement the new type property for the system error
This commit is contained in:
parent
ce3e8794a2
commit
0646f63404
@ -95,6 +95,7 @@ enum ErrorType {
|
|||||||
InternalError,
|
InternalError,
|
||||||
InvalidRequestError,
|
InvalidRequestError,
|
||||||
AuthenticationError,
|
AuthenticationError,
|
||||||
|
System,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ErrorType {
|
impl fmt::Display for ErrorType {
|
||||||
@ -105,6 +106,7 @@ impl fmt::Display for ErrorType {
|
|||||||
InternalError => write!(f, "internal"),
|
InternalError => write!(f, "internal"),
|
||||||
InvalidRequestError => write!(f, "invalid_request"),
|
InvalidRequestError => write!(f, "invalid_request"),
|
||||||
AuthenticationError => write!(f, "auth"),
|
AuthenticationError => write!(f, "auth"),
|
||||||
|
System => write!(f, "system"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,12 +242,12 @@ impl Code {
|
|||||||
|
|
||||||
match self {
|
match self {
|
||||||
// related to the setup
|
// related to the setup
|
||||||
IoError => ErrCode::invalid("io_error", StatusCode::UNPROCESSABLE_ENTITY),
|
IoError => ErrCode::system("io_error", StatusCode::UNPROCESSABLE_ENTITY),
|
||||||
TooManyOpenFiles => {
|
TooManyOpenFiles => {
|
||||||
ErrCode::invalid("too_many_open_files", StatusCode::UNPROCESSABLE_ENTITY)
|
ErrCode::system("too_many_open_files", StatusCode::UNPROCESSABLE_ENTITY)
|
||||||
}
|
}
|
||||||
NoSpaceLeftOnDevice => {
|
NoSpaceLeftOnDevice => {
|
||||||
ErrCode::invalid("no_space_left_on_device", StatusCode::UNPROCESSABLE_ENTITY)
|
ErrCode::system("no_space_left_on_device", StatusCode::UNPROCESSABLE_ENTITY)
|
||||||
}
|
}
|
||||||
|
|
||||||
// index related errors
|
// index related errors
|
||||||
@ -531,6 +533,10 @@ impl ErrCode {
|
|||||||
fn invalid(error_name: &'static str, status_code: StatusCode) -> ErrCode {
|
fn invalid(error_name: &'static str, status_code: StatusCode) -> ErrCode {
|
||||||
ErrCode { status_code, error_name, error_type: ErrorType::InvalidRequestError }
|
ErrCode { status_code, error_name, error_type: ErrorType::InvalidRequestError }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn system(error_name: &'static str, status_code: StatusCode) -> ErrCode {
|
||||||
|
ErrCode { status_code, error_name, error_type: ErrorType::System }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorCode for JoinError {
|
impl ErrorCode for JoinError {
|
||||||
|
Loading…
Reference in New Issue
Block a user