mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +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,
|
InvalidToken,
|
||||||
Maintenance,
|
Maintenance,
|
||||||
MissingAuthorizationHeader,
|
MissingAuthorizationHeader,
|
||||||
MissingHeader,
|
|
||||||
NotFound,
|
NotFound,
|
||||||
PayloadTooLarge,
|
PayloadTooLarge,
|
||||||
RetrieveDocument,
|
RetrieveDocument,
|
||||||
@ -107,10 +106,9 @@ impl Code {
|
|||||||
BadRequest => ErrCode::invalid("bad_request", StatusCode::BAD_REQUEST),
|
BadRequest => ErrCode::invalid("bad_request", StatusCode::BAD_REQUEST),
|
||||||
DocumentNotFound => ErrCode::internal("document_not_found", StatusCode::NOT_FOUND),
|
DocumentNotFound => ErrCode::internal("document_not_found", StatusCode::NOT_FOUND),
|
||||||
Internal => ErrCode::internal("internal", StatusCode::INTERNAL_SERVER_ERROR),
|
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),
|
Maintenance => ErrCode::internal("maintenance", StatusCode::SERVICE_UNAVAILABLE),
|
||||||
MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::FORBIDDEN),
|
MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED),
|
||||||
MissingHeader => ErrCode::authentication("missing_header", StatusCode::UNAUTHORIZED),
|
|
||||||
NotFound => ErrCode::invalid("not_found", StatusCode::NOT_FOUND),
|
NotFound => ErrCode::invalid("not_found", StatusCode::NOT_FOUND),
|
||||||
PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::PAYLOAD_TOO_LARGE),
|
PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::PAYLOAD_TOO_LARGE),
|
||||||
RetrieveDocument => ErrCode::internal("retrieve_document", StatusCode::BAD_REQUEST),
|
RetrieveDocument => ErrCode::internal("retrieve_document", StatusCode::BAD_REQUEST),
|
||||||
|
@ -46,7 +46,6 @@ pub enum Error {
|
|||||||
InvalidToken(String),
|
InvalidToken(String),
|
||||||
Maintenance,
|
Maintenance,
|
||||||
MissingAuthorizationHeader,
|
MissingAuthorizationHeader,
|
||||||
MissingHeader(String),
|
|
||||||
NotFound(String),
|
NotFound(String),
|
||||||
OpenIndex(String),
|
OpenIndex(String),
|
||||||
RetrieveDocument(u32, String),
|
RetrieveDocument(u32, String),
|
||||||
@ -71,7 +70,6 @@ impl ErrorCode for Error {
|
|||||||
InvalidToken(_) => Code::InvalidToken,
|
InvalidToken(_) => Code::InvalidToken,
|
||||||
Maintenance => Code::Maintenance,
|
Maintenance => Code::Maintenance,
|
||||||
MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
|
MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
|
||||||
MissingHeader(_) => Code::MissingHeader,
|
|
||||||
NotFound(_) => Code::NotFound,
|
NotFound(_) => Code::NotFound,
|
||||||
OpenIndex(_) => Code::OpenIndex,
|
OpenIndex(_) => Code::OpenIndex,
|
||||||
RetrieveDocument(_, _) => Code::RetrieveDocument,
|
RetrieveDocument(_, _) => Code::RetrieveDocument,
|
||||||
@ -153,10 +151,6 @@ impl Error {
|
|||||||
Error::DocumentNotFound(err.to_string())
|
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 {
|
pub fn bad_parameter(param: impl fmt::Display, err: impl fmt::Display) -> Error {
|
||||||
Error::BadParameter(param.to_string(), err.to_string())
|
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::InvalidToken(err) => write!(f, "Invalid API key: {}", err),
|
||||||
Self::Maintenance => f.write_str("Server is in maintenance, please try again later"),
|
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::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::NotFound(err) => write!(f, "{} not found", err),
|
||||||
Self::OpenIndex(err) => write!(f, "Impossible to open index; {}", 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),
|
Self::RetrieveDocument(id, err) => write!(f, "impossible to retrieve the document with id: {}; {}", id, err),
|
||||||
|
Loading…
Reference in New Issue
Block a user