use thiserror::Error;
#[derive(Debug, Error)]
pub enum ScoutError {
#[error(
"invalid index name `{0}`: must be non-empty; no whitespace or `/` `\\` `*` `?` `,` `+` `\"` `'` `;` or backtick; \
must not start with `.` `-` or `_`"
)]
InvalidIndexName(String),
#[error("invalid host: {0}")]
InvalidHost(String),
#[error("invalid field name `{0}`: only letters, digits, `_`, `-` and `.` are allowed")]
InvalidFieldName(String),
#[error("invalid search result: {0}")]
InvalidResult(String),
#[error("unsupported operation: {0}")]
Unsupported(String),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[cfg(any(
feature = "elasticsearch",
feature = "meilisearch",
feature = "typesense",
feature = "algolia"
))]
#[error("HTTP request failed: {0}")]
Http(#[from] reqwest::Error),
#[cfg(feature = "database")]
#[error("SQLite error: {0}")]
Sqlx(#[from] sqlx::Error),
#[cfg(any(
feature = "elasticsearch",
feature = "meilisearch",
feature = "typesense",
feature = "algolia",
feature = "xunsearch"
))]
#[error("backend engine request failed: {0}")]
Backend(String),
#[cfg(feature = "xunsearch")]
#[error("xunsearch error: {0}")]
XunSearch(String),
#[cfg(feature = "xunsearch")]
#[error("xunsearch I/O error: {0}")]
XunSearchIo(#[from] std::io::Error),
}
impl ScoutError {
pub fn pet_hint(&self) -> &'static str {
crate::pet::hint(self)
}
}
pub type Result<T> = std::result::Result<T, ScoutError>;