use thiserror::Error;
#[derive(Error, Debug)]
pub enum JudgyError {
#[error("Input validation error: {0}")]
InputValidation(String),
#[error("Judge accuracy too low for correction: TPR + TNR = {tpr_plus_tnr:.3} <= 1. Judge must be better than random")]
JudgeAccuracyTooLow { tpr_plus_tnr: f64 },
#[error("Bootstrap error: {0}")]
Bootstrap(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("CSV error: {0}")]
Csv(#[from] csv::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("Parse error: {0}")]
Parse(String),
#[error("Configuration error: {0}")]
Config(String),
}
pub type Result<T> = std::result::Result<T, JudgyError>;
impl JudgyError {
pub fn input_validation(msg: impl Into<String>) -> Self {
Self::InputValidation(msg.into())
}
pub fn bootstrap(msg: impl Into<String>) -> Self {
Self::Bootstrap(msg.into())
}
pub fn parse(msg: impl Into<String>) -> Self {
Self::Parse(msg.into())
}
pub fn config(msg: impl Into<String>) -> Self {
Self::Config(msg.into())
}
}