mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +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
|
||||
InvalidState,
|
||||
MissingPrimaryKey,
|
||||
PrimaryKeyAlreadyPresent,
|
||||
|
||||
// invalid documents FIXME make one error code?
|
||||
MissingDocumentId,
|
||||
@ -77,7 +78,8 @@ impl Code {
|
||||
// invalid state error
|
||||
InvalidState => ErrCode::internal("invalid_state", StatusCode::INTERNAL_SERVER_ERROR),
|
||||
// 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
|
||||
MissingDocumentId => ErrCode::invalid("MissingDocumentId", StatusCode::BAD_REQUEST),
|
||||
|
@ -26,7 +26,12 @@ impl error::Error for Error {}
|
||||
|
||||
impl ErrorCode for Error {
|
||||
fn error_code(&self) -> Code {
|
||||
// TODO populate with correct error codes
|
||||
Code::Internal
|
||||
use Error::*;
|
||||
|
||||
match self {
|
||||
FieldNameNotFound(_) => Code::Internal,
|
||||
MaxFieldsLimitExceeded => Code::MaxFieldsLimitExceeded,
|
||||
PrimaryKeyAlreadyPresent => Code::PrimaryKeyAlreadyPresent,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user