mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
change missing headers & auth status code
This commit is contained in:
parent
cff9e1fd94
commit
d007bf13f1
@ -70,7 +70,6 @@ pub enum Code {
|
||||
InvalidToken,
|
||||
Maintenance,
|
||||
MissingAuthorizationHeader,
|
||||
MissingHeader,
|
||||
NotFound,
|
||||
PayloadTooLarge,
|
||||
RetrieveDocument,
|
||||
@ -107,10 +106,9 @@ impl Code {
|
||||
BadRequest => ErrCode::invalid("bad_request", StatusCode::BAD_REQUEST),
|
||||
DocumentNotFound => ErrCode::internal("document_not_found", StatusCode::NOT_FOUND),
|
||||
Internal => ErrCode::internal("internal", StatusCode::INTERNAL_SERVER_ERROR),
|
||||
InvalidToken => ErrCode::authentication("invalid_token", StatusCode::UNAUTHORIZED),
|
||||
InvalidToken => ErrCode::authentication("invalid_token", StatusCode::FORBIDDEN),
|
||||
Maintenance => ErrCode::internal("maintenance", StatusCode::SERVICE_UNAVAILABLE),
|
||||
MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::FORBIDDEN),
|
||||
MissingHeader => ErrCode::authentication("missing_header", StatusCode::UNAUTHORIZED),
|
||||
MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED),
|
||||
NotFound => ErrCode::invalid("not_found", StatusCode::NOT_FOUND),
|
||||
PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::PAYLOAD_TOO_LARGE),
|
||||
RetrieveDocument => ErrCode::internal("retrieve_document", StatusCode::BAD_REQUEST),
|
||||
|
@ -46,7 +46,6 @@ pub enum Error {
|
||||
InvalidToken(String),
|
||||
Maintenance,
|
||||
MissingAuthorizationHeader,
|
||||
MissingHeader(String),
|
||||
NotFound(String),
|
||||
OpenIndex(String),
|
||||
RetrieveDocument(u32, String),
|
||||
@ -71,7 +70,6 @@ impl ErrorCode for Error {
|
||||
InvalidToken(_) => Code::InvalidToken,
|
||||
Maintenance => Code::Maintenance,
|
||||
MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
|
||||
MissingHeader(_) => Code::MissingHeader,
|
||||
NotFound(_) => Code::NotFound,
|
||||
OpenIndex(_) => Code::OpenIndex,
|
||||
RetrieveDocument(_, _) => Code::RetrieveDocument,
|
||||
@ -153,10 +151,6 @@ impl Error {
|
||||
Error::DocumentNotFound(err.to_string())
|
||||
}
|
||||
|
||||
pub fn missing_header(err: impl fmt::Display) -> Error {
|
||||
Error::MissingHeader(err.to_string())
|
||||
}
|
||||
|
||||
pub fn bad_parameter(param: impl fmt::Display, err: impl fmt::Display) -> Error {
|
||||
Error::BadParameter(param.to_string(), err.to_string())
|
||||
}
|
||||
@ -199,7 +193,6 @@ impl fmt::Display for Error {
|
||||
Self::InvalidToken(err) => write!(f, "Invalid API key: {}", err),
|
||||
Self::Maintenance => f.write_str("Server is in maintenance, please try again later"),
|
||||
Self::MissingAuthorizationHeader => f.write_str("You must have an authorization token"),
|
||||
Self::MissingHeader(header) => write!(f, "Header {} is missing", header),
|
||||
Self::NotFound(err) => write!(f, "{} not found", err),
|
||||
Self::OpenIndex(err) => write!(f, "Impossible to open index; {}", err),
|
||||
Self::RetrieveDocument(id, err) => write!(f, "impossible to retrieve the document with id: {}; {}", id, err),
|
||||
|
Loading…
Reference in New Issue
Block a user