1use std::fmt::Display;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
6pub enum ReedlineErrorVariants {
7 #[cfg(any(feature = "sqlite", feature = "sqlite-dynlib"))]
9 #[error("error within history database: {0}")]
10 HistoryDatabaseError(String),
11 #[error("error within history: {0}")]
12 OtherHistoryError(&'static str),
13 #[error("the history {history} does not support feature {feature}")]
14 HistoryFeatureUnsupported {
15 history: &'static str,
16 feature: &'static str,
17 },
18 #[error("I/O error: {0}")]
19 IOError(std::io::Error),
20}
21
22#[derive(Debug)]
24pub struct ReedlineError(pub ReedlineErrorVariants);
25
26impl Display for ReedlineError {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 self.0.fmt(f)
29 }
30}
31impl std::error::Error for ReedlineError {}
32
33pub type Result<T> = std::result::Result<T, ReedlineError>;