mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
error codes for schema
This commit is contained in:
parent
9c58ca7ce5
commit
e2546f2646
@ -36,6 +36,7 @@ pub enum Code {
|
|||||||
// invalid state error
|
// invalid state error
|
||||||
InvalidState,
|
InvalidState,
|
||||||
MissingPrimaryKey,
|
MissingPrimaryKey,
|
||||||
|
PrimaryKeyAlreadyPresent,
|
||||||
|
|
||||||
// invalid documents FIXME make one error code?
|
// invalid documents FIXME make one error code?
|
||||||
MissingDocumentId,
|
MissingDocumentId,
|
||||||
@ -77,7 +78,8 @@ impl Code {
|
|||||||
// invalid state error
|
// invalid state error
|
||||||
InvalidState => ErrCode::internal("invalid_state", StatusCode::INTERNAL_SERVER_ERROR),
|
InvalidState => ErrCode::internal("invalid_state", StatusCode::INTERNAL_SERVER_ERROR),
|
||||||
// FIXME probably not an internal statuscode there
|
// FIXME probably not an internal statuscode there
|
||||||
MissingPrimaryKey => ErrCode::internal("MissingPrimaryKey", StatusCode::INTERNAL_SERVER_ERROR),
|
MissingPrimaryKey => ErrCode::internal("missing_primary_key", StatusCode::INTERNAL_SERVER_ERROR),
|
||||||
|
PrimaryKeyAlreadyPresent => ErrCode::internal("primary_key_already_present", StatusCode::INTERNAL_SERVER_ERROR),
|
||||||
|
|
||||||
// invalid document
|
// invalid document
|
||||||
MissingDocumentId => ErrCode::invalid("MissingDocumentId", StatusCode::BAD_REQUEST),
|
MissingDocumentId => ErrCode::invalid("MissingDocumentId", StatusCode::BAD_REQUEST),
|
||||||
|
@ -26,7 +26,12 @@ impl error::Error for Error {}
|
|||||||
|
|
||||||
impl ErrorCode for Error {
|
impl ErrorCode for Error {
|
||||||
fn error_code(&self) -> Code {
|
fn error_code(&self) -> Code {
|
||||||
// TODO populate with correct error codes
|
use Error::*;
|
||||||
Code::Internal
|
|
||||||
|
match self {
|
||||||
|
FieldNameNotFound(_) => Code::Internal,
|
||||||
|
MaxFieldsLimitExceeded => Code::MaxFieldsLimitExceeded,
|
||||||
|
PrimaryKeyAlreadyPresent => Code::PrimaryKeyAlreadyPresent,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user