use thiserror::Error;
pub type Result<T> = core::result::Result<T, LearnerError>;
#[derive(Error, Debug)]
pub enum LearnerError {
#[error("Invalid identifier format")]
InvalidIdentifier,
#[error("Invalid source type, see `learner::paper::Source`")]
InvalidSource(String),
#[error(transparent)]
Network(#[from] reqwest::Error),
#[error("Paper not found")]
NotFound,
#[error("API error: {0}")]
ApiError(String),
#[error(transparent)]
Sqlite(#[from] rusqlite::Error),
#[error(transparent)]
AsyncSqlite(#[from] tokio_rusqlite::Error),
#[error(transparent)]
Path(#[from] std::io::Error),
#[error(transparent)]
ColumnOverflow(#[from] std::num::TryFromIntError),
#[error(transparent)]
Lopdf(#[from] lopdf::Error),
#[error("No model was chosen for the LLM.")]
LLMMissingModel,
#[error("No messages were supplied to send to the LLM.")]
LLMMissingMessage,
#[error("Tried to add a paper titled \"{0}\" that was already in the database.")]
DatabaseDuplicatePaper(String),
#[error("Retriever matched multiple different identifiers for a request: {0:?}")]
AmbiguousIdentifier(Vec<String>),
#[error(transparent)]
TomlDe(#[from] toml::de::Error),
#[error("{0}")]
Config(String),
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),
#[error("A resource must serialize into a flat Rust struct or JSON object.")]
InvalidResource,
}