mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-08 21:25:37 +00:00
Move `meilisearch_error` to `meilisearch_types::error` Move `meilisearch_lib::index_resolver::IndexUid` to `meilisearch_types::index_uid` Add a new `InvalidIndexUid` error in `meilisearch_types::index_uid`
23 lines
804 B
Rust
23 lines
804 B
Rust
use meilisearch_types::error::{Code, ErrorCode};
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum AuthenticationError {
|
|
#[error("The Authorization header is missing. It must use the bearer authorization method.")]
|
|
MissingAuthorizationHeader,
|
|
#[error("The provided API key is invalid.")]
|
|
InvalidToken,
|
|
// Triggered on configuration error.
|
|
#[error("An internal error has occurred. `Irretrievable state`.")]
|
|
IrretrievableState,
|
|
}
|
|
|
|
impl ErrorCode for AuthenticationError {
|
|
fn error_code(&self) -> Code {
|
|
match self {
|
|
AuthenticationError::MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
|
|
AuthenticationError::InvalidToken => Code::InvalidToken,
|
|
AuthenticationError::IrretrievableState => Code::Internal,
|
|
}
|
|
}
|
|
}
|