2022-10-13 15:02:59 +02:00
|
|
|
use meilisearch_types::error::{Code, ErrorCode};
|
2022-10-02 13:24:59 +02:00
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
#[derive(Debug, Error)]
|
|
|
|
pub enum Error {
|
2022-10-10 14:32:11 +02:00
|
|
|
#[error("Bad index name.")]
|
2022-10-03 16:12:01 +02:00
|
|
|
BadIndexName,
|
2022-10-10 14:32:11 +02:00
|
|
|
#[error("Malformed task.")]
|
|
|
|
MalformedTask,
|
2022-10-03 16:12:01 +02:00
|
|
|
|
2022-10-02 13:24:59 +02:00
|
|
|
#[error(transparent)]
|
|
|
|
Io(#[from] std::io::Error),
|
|
|
|
#[error(transparent)]
|
|
|
|
Serde(#[from] serde_json::Error),
|
2022-10-03 18:50:06 +02:00
|
|
|
#[error(transparent)]
|
|
|
|
Uuid(#[from] uuid::Error),
|
2022-10-02 13:24:59 +02:00
|
|
|
}
|
2022-10-13 15:02:59 +02:00
|
|
|
|
|
|
|
impl ErrorCode for Error {
|
|
|
|
fn error_code(&self) -> Code {
|
|
|
|
match self {
|
|
|
|
// Are these three really Internal errors?
|
2022-10-17 16:35:23 +02:00
|
|
|
// TODO look at that later.
|
2022-10-13 15:02:59 +02:00
|
|
|
Error::Io(_) => Code::Internal,
|
|
|
|
Error::Serde(_) => Code::Internal,
|
|
|
|
Error::Uuid(_) => Code::Internal,
|
|
|
|
|
|
|
|
// all these errors should never be raised when creating a dump, thus no error code should be associated.
|
|
|
|
Error::BadIndexName => Code::Internal,
|
|
|
|
Error::MalformedTask => Code::Internal,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|