use std::io;
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum CompareError {
#[error("cannot access {}", path.display())]
Io {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("{} is not valid", path.display())]
Json {
path: PathBuf,
#[source]
source: serde_json::Error,
},
#[error(transparent)]
Dataset(#[from] crate::dataset::DatasetError),
#[error(transparent)]
Prompt(#[from] crate::prompts::PromptError),
#[error("the judge failed on question {id}")]
Judge {
id: String,
#[source]
source: crate::llm::LlmError,
},
#[error("{} has no question with an answer: run `overbrainer split` first", .0.display())]
NoQuestions(PathBuf),
#[error("the GGUF on the target must be an absolute path, not {0}")]
RelativeModel(String),
#[error("no compare {0} in runs/")]
NotFound(String),
}
pub(crate) fn io_error(path: &std::path::Path) -> impl FnOnce(io::Error) -> CompareError + '_ {
move |source| CompareError::Io {
path: path.to_path_buf(),
source,
}
}
pub(crate) fn json_error(
path: &std::path::Path,
) -> impl FnOnce(serde_json::Error) -> CompareError + '_ {
move |source| CompareError::Json {
path: path.to_path_buf(),
source,
}
}