use std::io;
use thiserror::Error;
use crate::cc::feature::FType;
use crate::codebook::CodebookError;
#[derive(Debug, Error)]
pub enum CsvParseError {
#[error("io error: {0}")]
IoError(#[from] io::Error),
#[error("The csv contained no columns")]
NoColumns,
#[error("The first csv column must be named a case-insensitive variant of either 'ID' or 'Index'")]
FirstColumnNotNamedId,
#[error("One or more columns appear in the csv that do not appear in the codebook")]
MissingCodebookColumns,
#[error("One or more columns appear in the codebook that do not appear in the csv")]
MissingCsvColumns,
#[error("Different number of rows in codebook than in csv")]
CodebookAndDataRowMismatch,
#[error("There are duplicate column names in the codebook")]
DuplicateCodebookColumns,
#[error("There are duplicate column names in the csv")]
DuplicateCsvColumns,
#[error("There are duplicate row names in the csv")]
DuplicateCsvRows,
#[error("Could not parse value '{val}' at row '{row_name}', column {col_id} into {col_type:?}")]
InvalidValueForColumn {
col_id: usize,
row_name: String,
val: String,
col_type: FType,
},
#[error("The columns of the csv and codebook must be in the same order")]
CsvCodebookColumnsMisordered,
}
#[derive(Debug, Error)]
pub enum DefaultCodebookError {
#[error("provided an unsupported data source")]
UnsupportedDataSource,
#[error("error generating codebook from csv: {0}")]
Codebook(#[from] CodebookError),
}