use std::path::Path;
use colored::{ColoredString, Colorize};
use thiserror::Error;
fn path_to_yellow(path: &Path) -> ColoredString {
path.to_str().unwrap().yellow()
}
#[derive(Error, Debug)]
pub enum ParseTprError {
#[error("{} file '{}' could not be opened for reading", "error:".red().bold(), path_to_yellow(.0))]
CouldNotOpen(Box<Path>),
#[error("{} could not read data from a tpr file (`{}`)", "error:".red().bold(), .0.to_string().yellow())]
CouldNotRead(#[from] std::io::Error),
#[error("{} parsed file is not a tpr file", "error:".red().bold())]
NotTpr,
#[error("{} unsupported tpr file precision `{}`", "error:".red().bold(), .0.to_string().yellow())]
UnsupportedPrecision(i32),
#[error("{} unsupported tpr file version `{}`", "error:".red().bold(), .0.to_string().yellow())]
UnsupportedVersion(i32),
#[error("{} invalid SymTable call: `{}` is out-of-range of the SymTable", "error:".red().bold(), .0.to_string().yellow())]
IndexNotInSymTable(i32),
#[error("{} discrepancy in Interaction of type `{}`: the number of instances is not divisible by the number of interacting atoms + 1",
"error:".red().bold(), .0.to_string().yellow())]
InteractionDiscrepancy(i32),
#[error("{} interaction type index `{}` does not exist", "error:".red().bold(), .0.to_string().yellow())]
InvalidInteractionType(i32),
#[error("{} could not construct molecular topology", "error:".red().bold())]
CouldNotConstructTopology,
#[error("{} inconsistent number of atoms in the tpr file (expected `{}` atoms, got `{}` atoms)", "error:".red().bold(), .0.to_string().yellow(), .1.to_string().yellow())]
InconsistentNumberOfAtoms(i32, i32),
#[error("{} invalid number of atoms (`{}`) involved in a bond", "error:".red().bold(), .0.to_string().yellow())]
InvalidNumberOfBondedAtoms(usize),
#[error("{} invalid number of atoms (`{}`) involved in a settle interaction", "error".red().bold(), .0.to_string().yellow())]
InvalidNumberOfSettleAtoms(usize),
#[error("{} invalid intermolecular exclusion group size (expected a positive value, got `{}`)", "error:".red().bold(), .0.to_string().yellow())]
InvalidIntermolecularExclusionGroupSize(i64),
}