MeiliSearch/meilisearch-schema/src/error.rs

25 lines
708 B
Rust
Raw Normal View History

2020-01-10 18:20:30 +01:00
use std::{error, fmt};
pub type SResult<T> = Result<T, Error>;
#[derive(Debug)]
pub enum Error {
2020-01-13 19:10:58 +01:00
FieldNameNotFound(String),
PrimaryKeyAlreadyPresent,
2020-01-10 18:20:30 +01:00
MaxFieldsLimitExceeded,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::Error::*;
match self {
2020-01-29 18:30:21 +01:00
FieldNameNotFound(field) => write!(f, "The field {:?} doesn't exist", field),
PrimaryKeyAlreadyPresent => write!(f, "The schema already have an primary key. It's impossible to update it"),
2020-01-29 18:30:21 +01:00
MaxFieldsLimitExceeded => write!(f, "The maximum of possible reattributed field id has been reached"),
2020-01-10 18:20:30 +01:00
}
}
}
impl error::Error for Error {}