mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-27 07:00:05 +01:00
fix status code
This commit is contained in:
parent
4254cfbce5
commit
51b3139c0b
@ -7,7 +7,7 @@ use std::{fs, thread};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use heed::types::{Str, Unit, SerdeBincode};
|
||||
use heed::{CompactionOption, Result as ZResult};
|
||||
use heed::CompactionOption;
|
||||
use log::{debug, error};
|
||||
use meilisearch_schema::Schema;
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl Code {
|
||||
// index related errors
|
||||
CreateIndex => ErrCode::invalid("create_index", StatusCode::BAD_REQUEST),
|
||||
IndexAlreadyExists => ErrCode::invalid("existing_index", StatusCode::BAD_REQUEST),
|
||||
IndexNotFound => ErrCode::invalid("index_not_found", StatusCode::BAD_REQUEST),
|
||||
IndexNotFound => ErrCode::invalid("index_not_found", StatusCode::NOT_FOUND),
|
||||
InvalidIndexUid => ErrCode::invalid("invalid_index_uid", StatusCode::BAD_REQUEST),
|
||||
OpenIndex => ErrCode::internal("open_index", StatusCode::INTERNAL_SERVER_ERROR),
|
||||
|
||||
@ -86,21 +86,21 @@ impl Code {
|
||||
MaxFieldsLimitExceeded => ErrCode::invalid("max_field_limit_exceeded", StatusCode::BAD_REQUEST),
|
||||
|
||||
Filter => ErrCode::invalid("fitler", StatusCode::BAD_REQUEST),
|
||||
Facet => ErrCode::invalid("fitler", StatusCode::BAD_REQUEST),
|
||||
Facet => ErrCode::invalid("facet", StatusCode::BAD_REQUEST),
|
||||
|
||||
BadParameter => ErrCode::invalid("bad_parameter", StatusCode::BAD_REQUEST),
|
||||
BadRequest => ErrCode::invalid("bad_request", StatusCode::BAD_REQUEST),
|
||||
RetrieveDocument => ErrCode::invalid("retrieve_document", StatusCode::BAD_REQUEST),
|
||||
SearchDocuments => ErrCode::invalid("search_document", StatusCode::BAD_REQUEST),
|
||||
DocumentNotFound => ErrCode::invalid("document_not_found", StatusCode::BAD_REQUEST),
|
||||
NotFound => ErrCode::invalid("not_found", StatusCode::BAD_REQUEST),
|
||||
InvalidToken => ErrCode::invalid("invalid_token", StatusCode::BAD_REQUEST),
|
||||
MissingHeader => ErrCode::invalid("missing_header", StatusCode::BAD_REQUEST),
|
||||
MissingAuthorizationHeader => ErrCode::invalid("missing_authorization_header", StatusCode::BAD_REQUEST),
|
||||
Internal => ErrCode::internal("internal", StatusCode::BAD_REQUEST),
|
||||
Maintenance => ErrCode::invalid("maintenance", StatusCode::BAD_REQUEST),
|
||||
PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::BAD_REQUEST),
|
||||
UnsupportedMediaType => ErrCode::invalid("unsupported_media_type", StatusCode::BAD_REQUEST),
|
||||
DocumentNotFound => ErrCode::invalid("document_not_found", StatusCode::NOT_FOUND),
|
||||
NotFound => ErrCode::invalid("not_found", StatusCode::NOT_FOUND),
|
||||
InvalidToken => ErrCode::authentication("invalid_token", StatusCode::UNAUTHORIZED),
|
||||
MissingHeader => ErrCode::authentication("missing_header", StatusCode::UNAUTHORIZED),
|
||||
MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::FORBIDDEN),
|
||||
Internal => ErrCode::internal("internal", StatusCode::INTERNAL_SERVER_ERROR),
|
||||
Maintenance => ErrCode::invalid("maintenance", StatusCode::SERVICE_UNAVAILABLE),
|
||||
PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::PAYLOAD_TOO_LARGE),
|
||||
UnsupportedMediaType => ErrCode::invalid("unsupported_media_type", StatusCode::UNSUPPORTED_MEDIA_TYPE),
|
||||
_ => ErrCode::invalid("other", StatusCode::BAD_REQUEST),
|
||||
}
|
||||
}
|
||||
@ -119,6 +119,10 @@ impl Code {
|
||||
pub fn r#type(&self) -> String {
|
||||
self.err_code().err_type.to_string()
|
||||
}
|
||||
|
||||
pub fn url(&self) -> String {
|
||||
format!("docs.meilisearch.come/error/{}", self.name())
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal structure providing a convenient way to create error codes
|
||||
|
Loading…
x
Reference in New Issue
Block a user